netsoul
Version:
netsoul protocol library
17 lines (14 loc) • 414 B
text/coffeescript
class PubSub
constructor: ->
= {}
on: (event, callback, id = null) =>
[event] = [] if not [event]?
[event].push
callback: callback
id: id
emit: (event, args...) =>
return false if not [event]?
for subscription in [event]
subscription.callback args...
module.exports =
PubSub: PubSub