Skip to content

Instantly share code, notes, and snippets.

@kbshl
Last active October 30, 2017 18:36
Show Gist options
  • Save kbshl/4107f3329c79fca98415 to your computer and use it in GitHub Desktop.
Save kbshl/4107f3329c79fca98415 to your computer and use it in GitHub Desktop.
Titanium Mobile: Using JS-only event dispatcher
var dispatcher = require('dispatcher');
function onLogOutButtonClick(e) {
dispatcher.trigger('logout');
}
var dispatcher = require('dispatcher');
dispatcher.on('logout', function onLogOut(e) {
// so the dispatcher doesn't keep us from GC
dispatcher.off('logOut', onLogOut);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment