subscribe and unsubscribe
This commit is contained in:
parent
03e653acd3
commit
bf1ba794bd
@ -222,6 +222,7 @@ render-navbar = ->
|
||||
h \div.navbar-start [
|
||||
h \a.navbar-item.is-size-2 {
|
||||
onclick: ->
|
||||
model.todod-ws.unsubscribe model.viewed-project.id
|
||||
model.viewed-project := void
|
||||
model.current-view := "project-list"
|
||||
} [ "⌂" ]
|
||||
@ -243,6 +244,7 @@ render-project-list = ->
|
||||
onclick: ->
|
||||
model.current-view := "project"
|
||||
model.viewed-project := project.id
|
||||
model.todod-ws.subscribe project.id
|
||||
model.todod-ws.get-list project.id
|
||||
model.todod-ws.get-tasks project.id
|
||||
} [
|
||||
|
@ -9,16 +9,18 @@ module.exports = {
|
||||
self = {}
|
||||
|
||||
request-types = {
|
||||
"list-lists": 0
|
||||
"get-list": 1
|
||||
"add-list": 2
|
||||
"edit-list": 3
|
||||
"remove-list": 4
|
||||
"get-tasks": 5
|
||||
"get-task": 6
|
||||
"add-task": 7
|
||||
"remove-task": 8
|
||||
"edit-task": 9
|
||||
"list-lists": 0
|
||||
"get-list": 1
|
||||
"add-list": 2
|
||||
"edit-list": 3
|
||||
"remove-list": 4
|
||||
"get-tasks": 5
|
||||
"get-task": 6
|
||||
"add-task": 7
|
||||
"remove-task": 8
|
||||
"edit-task": 9
|
||||
"subscribe": 10
|
||||
"unsubscribe": 11
|
||||
}
|
||||
|
||||
response-types = {
|
||||
@ -33,6 +35,8 @@ module.exports = {
|
||||
"task-created": 8
|
||||
"task-removed": 9
|
||||
"task-updated": 10
|
||||
"subscribed": 11
|
||||
"unsubscribed": 12
|
||||
}
|
||||
|
||||
# users can record functions to run on events
|
||||
@ -162,5 +166,17 @@ module.exports = {
|
||||
|
||||
self.send request-types[\edit-task], JSON.stringify payload
|
||||
|
||||
self.subscribe = (list-id) ->
|
||||
self.send request-types[\subscribe], JSON.stringify {
|
||||
token: self.token
|
||||
list: list-id
|
||||
}
|
||||
|
||||
self.unsubscribe = (list-id) ->
|
||||
self.send request-types[\unsubscribe], JSON.stringify {
|
||||
token: self.token
|
||||
list: list-id
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user