How to use the inferno-mobx.EventEmitter function in inferno-mobx

To help you get started, we’ve selected a few inferno-mobx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github infernojs / inferno / packages / inferno-mobx / __tests__ / extra / eventemitter.spec.js View on Github external
it('Should emit the change data to all active listeners', () => {
    const emitter = new EventEmitter();
    const listener1 = function() {};
    const listener2 = function(data) {
      console.error(data);
    };

    spyOn(console, 'error');

    expect(emitter.listeners.length).toEqual(0);

    const listener = emitter.on(listener1);
    const listenerTwo = emitter.on(listener2);

    expect(emitter.listeners.length).toEqual(2);
    expect(emitter.listeners[0]).toEqual(listener1);

    listener();
github infernojs / inferno / packages / inferno-mobx / __tests__ / extra / eventemitter.spec.js View on Github external
it('Should do nothing if removing same callback twice/or more', () => {
    const emitter = new EventEmitter();
    const listener1 = function() {};
    expect(emitter.listeners.length).toEqual(0);

    const listener = emitter.on(listener1);

    expect(emitter.listeners.length).toEqual(1);
    expect(emitter.listeners[0]).toEqual(listener1);

    listener();
    listener();
    listener();

    expect(emitter.listeners.length).toEqual(0);
  });

inferno-mobx

Official Inferno bindings for Mobx

MIT
Latest version published 10 months ago

Package Health Score

78 / 100
Full package analysis