* Notify this Observable instance with some data. This causes all event * handlers on the Observable instance to be called, as well as any 'global' * event handlers set on the instance's class. * * @param data an object that satisfies the EventData interface, though with * an optional 'obj
(data: T)
| 407 | * will implicitly be set as this Observable instance. |
| 408 | */ |
| 409 | public notify<T extends Optional<EventData, 'object'>>(data: T): void { |
| 410 | data.object = data.object || this; |
| 411 | const dataWithObject = data as EventData; |
| 412 | |
| 413 | const eventClass = this.constructor.name; |
| 414 | this._globalNotify(eventClass, 'First', dataWithObject); |
| 415 | |
| 416 | const observers = this._observers[data.eventName]; |
| 417 | if (observers) { |
| 418 | Observable._fireEvent(observers, dataWithObject); |
| 419 | } |
| 420 | |
| 421 | this._globalNotify(eventClass, '', dataWithObject); |
| 422 | } |
| 423 | |
| 424 | private static _fireEvent<T extends EventData>(observers: Array<ListenerEntry>, data: T): void { |
| 425 | const length = observers.length; |
no test coverage detected