A simple publisher-subscriber implementation. Event

Constructors

Properties

Constructors

Properties

notify: (args: Object, e: EventData, scope: Object) => any

Fires an event notifying all subscribers.

Type declaration

    • (args: Object, e: EventData, scope: Object): any
    • Parameters

      • args: Object

        {Object} Additional data object to be passed to all handlers.

      • e: EventData

        {EventData} Optional. An EventData object to be passed to all handlers. For DOM events, an existing W3C/jQuery event object can be passed in.

      • scope: Object

        {Object} Optional. The scope ("this") within which the handler will be executed. If not specified, the scope will be set to the Event instance.

      Returns any

subscribe: (fn: Function) => void

Adds an event handler to be called when the event is fired.

Event handler will receive two arguments - an EventData and the data object the event was fired with.

Type declaration

    • (fn: Function): void
    • Parameters

      • fn: Function

        {Function} Event handler.

      Returns void

unsubscribe: (fn: Function) => void

Removes an event handler added with subscribe(fn).

Type declaration

    • (fn: Function): void
    • Parameters

      • fn: Function

        {Function} Event handler to be removed.

      Returns void