Explorar el Código

:pencil: adding in some comments

tags/0.0.1
J hace 4 años
padre
commit
f35aab9a18

+ 33
- 3
frontend/src/services/chat.service.js Ver fichero

@@ -47,24 +47,37 @@ const testMessage = new ChatMessage({
47 47
 })
48 48
 const MAIN_CHANNEL = 'hello_world'
49 49
 
50
+/** Singleton that holds all our chat information */
50 51
 class Chatter {
52
+    /**
53
+     * Create our chatter instance
54
+     * @return {Chatter} our chatter instance object
55
+     */
51 56
     constructor() {
57
+        // Map of each active chat
52 58
         this.groupings = {}
59
+
60
+        // Our pubnub instance
53 61
         this.provider = null
62
+
63
+        // UUID used to identify unique users
54 64
         this.uuid = null
55 65
 
56 66
         // Setup the main channel
57 67
         this.subscriptions = [MAIN_CHANNEL]
58
-        
59 68
         this.listeners = {
60 69
             status: async e => {
61 70
                 if (e.category !== "PNConnectedCategory") return
62
-                await this._publish(this.subscriptions[0], testMessage)
71
+                await this.publish(this.subscriptions[0], testMessage)
63 72
             },
64 73
             message: this._onMessage,
65 74
             presence: this._onPresence
66 75
         }
67 76
     }
77
+    /**
78
+     * Callback that fires on every message
79
+     * @param {event} e
80
+     */
68 81
     async _onMessage(e) {
69 82
         console.log(e.message.title)
70 83
         console.log(e.message.description)
@@ -79,12 +92,29 @@ class Chatter {
79 92
         this._listenFor({ listeners: this.listeners })
80 93
         this._subscribe(this.subscriptions)
81 94
     }
82
-    async _publish(channel, message) {
95
+    /**
96
+     * Send a message to a channel
97
+     * example = new ChatMessage({ title: 'example', description: 'ni' })
98
+     * Facade so we can hide provider specific methods
99
+     * @param {string} channel
100
+     * @param {ChatMessage} message
101
+     * @return {object} timestamp
102
+     */
103
+    async publish(channel, message) {
83 104
         return await providerMethods['publish']({ channel, message })
84 105
     }
106
+    /** 
107
+     * Subscribe to a channels
108
+     * Facade so we can hide provider specific methods
109
+     * @param {array} channels
110
+    */
85 111
     _subscribe(channels) {
86 112
         providerMethods['subscribe']({ channels })
87 113
     }
114
+    /** 
115
+     * Listen to events and set callbacks
116
+     * Facade so we can hide provider specific methods
117
+    */
88 118
     _listenFor({ listeners }) {
89 119
         providerMethods['listen'](listeners)
90 120
     }

+ 7
- 0
frontend/src/services/notification.service.js Ver fichero

@@ -1,5 +1,9 @@
1 1
 import { remote } from '../utils/db'
2 2
 
3
+/**
4
+ * Base notifier class
5
+ * @param {number} profileId needed to listen for events for this profile
6
+ */
3 7
 class Toaster {
4 8
     constructor(profileId) {
5 9
         this.url = `${remote}/notification/${profileId}/subscribe`
@@ -12,6 +16,9 @@ class Toaster {
12 16
     }
13 17
 }
14 18
 
19
+/**
20
+ * Example extension that listens for 'stonk' events
21
+ */
15 22
 class StonkAlert extends Toaster {
16 23
     constructor(profileId) {
17 24
         super(profileId)

+ 0
- 1
frontend/src/views/home.vue Ver fichero

@@ -63,7 +63,6 @@ export default {
63 63
             const testAccountUUID = import.meta.env.VITE_TEST_ACCOUNT_UUID
64 64
             c.setup(testAccountUUID)
65 65
             console.log('---')
66
-            console.log(c)
67 66
         },
68 67
         processQueue(queueList) {
69 68
             const formattedList = []

Loading…
Cancelar
Guardar