Skip to content

Instantly share code, notes, and snippets.

@cupofjoakim
Created April 2, 2015 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cupofjoakim/83de143b506cd1a915bd to your computer and use it in GitHub Desktop.
Save cupofjoakim/83de143b506cd1a915bd to your computer and use it in GitHub Desktop.
framerjs pubsub
exports.pubsub = (->
listeners = {}
subscribe: (name, callback) ->
listeners[name] = [] unless listeners[name]
listeners[name].push callback
publish: (name) ->
args = Array::slice.call(arguments, 1)
if listeners[name]
i = 0
while i < listeners[name].length
listeners[name][i].apply null, args
i++
)()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment