Browse Source

:pencil: adding in some comments

tags/0.0.1
J 4 years ago
parent
commit
f35aab9a18

+ 33
- 3
frontend/src/services/chat.service.js View File

47
 })
47
 })
48
 const MAIN_CHANNEL = 'hello_world'
48
 const MAIN_CHANNEL = 'hello_world'
49
 
49
 
50
+/** Singleton that holds all our chat information */
50
 class Chatter {
51
 class Chatter {
52
+    /**
53
+     * Create our chatter instance
54
+     * @return {Chatter} our chatter instance object
55
+     */
51
     constructor() {
56
     constructor() {
57
+        // Map of each active chat
52
         this.groupings = {}
58
         this.groupings = {}
59
+
60
+        // Our pubnub instance
53
         this.provider = null
61
         this.provider = null
62
+
63
+        // UUID used to identify unique users
54
         this.uuid = null
64
         this.uuid = null
55
 
65
 
56
         // Setup the main channel
66
         // Setup the main channel
57
         this.subscriptions = [MAIN_CHANNEL]
67
         this.subscriptions = [MAIN_CHANNEL]
58
-        
59
         this.listeners = {
68
         this.listeners = {
60
             status: async e => {
69
             status: async e => {
61
                 if (e.category !== "PNConnectedCategory") return
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
             message: this._onMessage,
73
             message: this._onMessage,
65
             presence: this._onPresence
74
             presence: this._onPresence
66
         }
75
         }
67
     }
76
     }
77
+    /**
78
+     * Callback that fires on every message
79
+     * @param {event} e
80
+     */
68
     async _onMessage(e) {
81
     async _onMessage(e) {
69
         console.log(e.message.title)
82
         console.log(e.message.title)
70
         console.log(e.message.description)
83
         console.log(e.message.description)
79
         this._listenFor({ listeners: this.listeners })
92
         this._listenFor({ listeners: this.listeners })
80
         this._subscribe(this.subscriptions)
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
         return await providerMethods['publish']({ channel, message })
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
     _subscribe(channels) {
111
     _subscribe(channels) {
86
         providerMethods['subscribe']({ channels })
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
     _listenFor({ listeners }) {
118
     _listenFor({ listeners }) {
89
         providerMethods['listen'](listeners)
119
         providerMethods['listen'](listeners)
90
     }
120
     }

+ 7
- 0
frontend/src/services/notification.service.js View File

1
 import { remote } from '../utils/db'
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
 class Toaster {
7
 class Toaster {
4
     constructor(profileId) {
8
     constructor(profileId) {
5
         this.url = `${remote}/notification/${profileId}/subscribe`
9
         this.url = `${remote}/notification/${profileId}/subscribe`
12
     }
16
     }
13
 }
17
 }
14
 
18
 
19
+/**
20
+ * Example extension that listens for 'stonk' events
21
+ */
15
 class StonkAlert extends Toaster {
22
 class StonkAlert extends Toaster {
16
     constructor(profileId) {
23
     constructor(profileId) {
17
         super(profileId)
24
         super(profileId)

+ 0
- 1
frontend/src/views/home.vue View File

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

Loading…
Cancel
Save