Last active
August 29, 2015 14:10
-
-
Save costa/f484576d41030e9130a7 to your computer and use it in GitHub Desktop.
Rails: asynchronous pusher clientside initialisation snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... 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