Constructor Summary
| Public Constructor | ||
| public |
Observable constructor |
|
Method Summary
| Public Methods | ||
| public |
Notify all observers of specified event type |
|
| public |
Register callback to be called with events of specified type |
|
Public Constructors
Public Methods
public notify(type: string, data: *) source
Notify all observers of specified event type
Params:
| Name | Type | Attribute | Description |
| type | string | Event type |
|
| data | * | Event data |
public on(type: string, callback: Function): Function source
Register callback to be called with events of specified type
Callback will be called with an argument depending on the type of event.
Example:
const observable = new Observable();
const off = observable.on('foo', (data) => {
console.log(`Foo!`, data);
});
// To stop observing events at a later time:
off();
Manual
Reference
Source
Test
