oomph
Version:
Object Oriented javascript models for the client and the server
30 lines (23 loc) • 804 B
text/coffeescript
publishSubscribe =
moduleName: "publishSubscribe"
broadcast: (ev, data) ->
= {} if !
_callbackList = [ev]
return this if ! || !_callbackList
_callbackList.forEach (fn) =>
fn.call(this, data)
return this
listen: (ev, fn) ->
= {} if !
([ev] || [ev] = []).push fn
return this
removeListener: (ev, fn) ->
if and [ev]
callbackList = [ev]
index = callbackList.indexOf fn
if index > -1
callbackList.splice(index, 1)
removeAllListenersOn: (ev) ->
if and [ev]
delete [ev]
module.exports = publishSubscribe