class MessageQueue constructor listeners send type data for listener i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
class MessageQueue
constructor: ->
@listeners = {}
@send: (type, data) ->
for listener in @listeners[type]
listener(data)
@subscribe: (type, listener) ->
if not type in @listeners
@listeners[type] = []
@listeners[type].push(listener)