Skip to content

Instantly share code, notes, and snippets.

@catkins
Created November 16, 2014 06:06
Show Gist options
  • Save catkins/3145bee11b76f4e4e907 to your computer and use it in GitHub Desktop.
Save catkins/3145bee11b76f4e4e907 to your computer and use it in GitHub Desktop.
init: function() {
var callback = this._handleStorageEvent.bind(this);
$(window).on('storage', callback);
}
_handleStorageEvent: function(event) {
var storageEvent = event.originalEvent;
var storageKey = storageEvent.key;
var tokens = storageKey.split(':');
var namespace = tokens[0];
var key = tokens[1];
if (key && namespace === this.get('namespace')) {
this.notifyPropertyChange(key);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment