2020-01-20 08:12:22 +03:00
|
|
|
import EventEmitter from '../eventemitter3/index.js';
|
2020-01-02 11:06:52 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple adapter sub-class of Nodejs-like EventEmitter.
|
|
|
|
*/
|
|
|
|
export class Observer extends EventEmitter {
|
|
|
|
/**
|
|
|
|
* We simply want to pass along the event-name itself
|
|
|
|
* in every call to a handler, which is the purpose of our `trigger` method
|
|
|
|
* extending the standard API.
|
|
|
|
*/
|
2020-01-20 08:12:22 +03:00
|
|
|
trigger(event, ...data) {
|
2020-01-02 11:06:52 +03:00
|
|
|
this.emit(event, event, ...data);
|
|
|
|
}
|
|
|
|
}
|