# All files / src observer.js

100% Statements 1/1
100% Branches 0/0
100% Functions 1/1
100% Lines 1/1

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23

    162x

     import { EventEmitter } from 'eventemitter3';

    /**
     * @class
     *
     * Simple adapter sub-class of Nodejs-like 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.
     *
     */
    export class Observer extends EventEmitter {
      /**
       *
       * @param {string} event
       * @param {any} data
       */
      trigger (event, ...data) {
        this.emit(event, event, ...data);
      }
    }