Skip to content

Instantly share code, notes, and snippets.

@jacob414
Created February 17, 2011 15:07
Show Gist options
  • Save jacob414/831888 to your computer and use it in GitHub Desktop.
Save jacob414/831888 to your computer and use it in GitHub Desktop.
Micro global message bus in 4 LOC CoffeeScript
# Really, really tiny message bus
# Yes, I know it leaks.
usig._bus = {}
usig.connect = (msg, cb) -> (usig._bus[msg] ?= []).push(cb)
usig.signal = (msg, args...) ->
cb args... for cb in usig._bus[msg] if usig._bus[msg]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment