Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
framerjs pubsub
exports.pubsub = (->
listeners = {}
subscribe: (name, callback) ->
listeners[name] = [] unless listeners[name]
listeners[name].push callback
publish: (name) ->
args =, 1)
if listeners[name]
i = 0
while i < listeners[name].length
listeners[name][i].apply null, args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.