Skip to main content
Version: 2.2.0

Events – durandal/events

caution

The interface documentation for this module is incomplete. Declarations may be missing or invalid.

Durandal events originate from backbone.js but also combine some ideas from signals.js as well as some additional improvements. Events can be installed into any object and are installed into the app module by default for convenient app-wide eventing.

Classes​

Events (export=)​

Creates an object with eventing capabilities.

static includeIn(targetObject): void
Adds eventing capabilities to the specified object.
  • (param) targetObject – The object to add eventing capabilities to.
on(events: string, callback?, context?): Subscription | this
Creates a subscription or registers a callback for the specified event.
  • (param) events – One or more events, separated by white space.
  • (param) callback – The callback function to invoke when the event is triggered. If callback is not provided, a subscription instance is returned.
  • (param) context – An object to use as this when invoking the callback.
  • returns – A subscription is returned if no callback is supplied, otherwise the events object is returned for chaining.
off(events?: string, callback?, context?): this
Removes the callbacks for the specified events.
  • (param) events – One or more events, separated by white space to turn off. If no events are specified, then the callbacks will be removed.
  • (param) callback – The callback function to remove. If callback is not provided, all callbacks for the specified events will be removed.
  • (param) context – The object that was used as this. Callbacks with this context will be removed.
trigger(events: string, ...args): this
Triggers the specified events.
  • (param) events – One or more events, separated by white space to trigger.
  • (internal params) ...args
proxy(events: string): (arg?) => this
Creates a function that will trigger the specified events when called. Simplifies proxying jQuery (or other) events through to the events object.
  • (param) events – One or more events, separated by white space to trigger by invoking the returned function.
  • returns – Calling the function will invoke the previously specified events on the events object.

Subscription​

Represents an event subscription.

(internal) owner
(internal) events
constructor(owner?, events?)
off(): this
Cancels the subscription.
on = Subscription.prototype.then
then(callback?, context?): this
Attaches a callback to the event subscription.
  • (param) callback – The callback function to invoke when the event is triggered.
  • (param) context – An object to use as this when invoking the callback.