RSVP.EventTarget#off()

off (eventName, callback) private

Defined in bower_components/rsvp/lib/rsvp/events.js:109

You can use off to stop firing a particular callback for an event:

function doStuff() { // do stuff! }
object.on('stuff', doStuff);

object.trigger('stuff'); // doStuff will be called

// Unregister ONLY the doStuff callback
object.off('stuff', doStuff);
object.trigger('stuff'); // doStuff will NOT be called

If you don't pass a callback argument to off, ALL callbacks for the event will not be executed when the event fires. For example:

var callback1 = function(){};
var callback2 = function(){};

object.on('stuff', callback1);
object.on('stuff', callback2);

object.trigger('stuff'); // callback1 and callback2 will be executed.

object.off('stuff');
object.trigger('stuff'); // callback1 and callback2 will not be executed!

Parameters:

eventName String
event to stop listening to
callback Function
optional argument. If given, only the function given will be removed from the event's callback queue. If no `callback` argument is given, all callbacks will be removed from the event's callback queue.
doc_EmberJs
2016-11-30 16:53:22
Comments
Leave a Comment

Please login to continue.