Skip to content

Instantly share code, notes, and snippets.

@costa
Last active August 29, 2015 14:10
Show Gist options
  • Save costa/f484576d41030e9130a7 to your computer and use it in GitHub Desktop.
Save costa/f484576d41030e9130a7 to your computer and use it in GitHub Desktop.
Rails: asynchronous pusher clientside initialisation snippet
# ... somewhere in your Backbone app init function, after initialising the "@things" collection:
pusher_async pusher_or_key, (pusher)=>
pusher.connection.bind 'connected', => @things.fetch()
new Backpusher pusher.subscribe(channel), @things
# ... where channel's value is being rendered in the caller template like this:
"#{ENV['FAKE_PUSHER']? PusherFake.javascript : Pusher.key.to_json}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment