# All files / src observer.js

100% Statements 9/9
100% Branches 0/0
100% Functions 2/2
100% Lines 5/5

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

    16x

    209x
    209x

    16x
     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);
      }
    }