Last active
December 20, 2015 12:59
-
-
Save ejholmes/6135198 to your computer and use it in GitHub Desktop.
Turbolinks support for Pusher.js
This file contains 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
;(function($, Pusher) { | |
/* Resets all callbacks */ | |
Pusher.prototype.reset = function() { | |
$.each(this.channels.channels, function(name, channel) { | |
channel.callbacks._callbacks = {} | |
}) | |
} | |
$(document).on('page:receive', function() { | |
$.each(Pusher.instances, function(index, instance) { | |
instance.reset() | |
}) | |
}) | |
})(jQuery, Pusher); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm actually having trouble getting this to work properly. My connections keep stacking with just one user on the site.
The order of my js is:
pusher.min
pusher.turbolinks (gist above)
turbolinks
Still stacking connections though.