How to use the tiny-emitter function in tiny-emitter

To help you get started, we’ve selected a few tiny-emitter 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 govau / performance-dashboard / client / src / dashboard / scripts / page.js View on Github external
constructor(options) {
    this.options = options;
    this.emitter = new Emitter();
    this.initBtlApp();

    // todo - refactor these in to the app
    this.runOnResize();
    this.runHighContrastSwitch();
  }
github zenorocha / clipboard.js / test / clipboard-action.js View on Github external
it('should select text from non-editable element', () => {
            let clip = new ClipboardAction({
                emitter: new Emitter(),
                container: document.body,
                target: document.querySelector('#paragraph')
            });

            assert.equal(clip.selectedText, clip.target.textContent);
        });
    });
github webcreate / infinite-ajax-scroll / test / events_spec.js View on Github external
it('should call event listener', () => {
    const emitter = new Emitter();

    const container = document.createElement('div');

    const ias = new InfiniteAjaxScroll(container, {emitter});

    const spy = {
      foo() {}
    };

    cy.spy(spy, 'foo');

    ias.on('my-event', spy.foo);

    emitter.emit('my-event', 'data1');
    emitter.emit('my-event', 'data2');
github caleb531 / connect-four / test / session.spec.js View on Github external
before(function () {
    connect = sinon.stub(io, 'connect');
    socket = new Emitter();
    connect.returns(socket);
  });
github jonataswalker / scroll-watcher / src / main.js View on Github external
watch(element, opt_offset) {
    assert(
      typeof element === 'string' || isElement(element),
      '@param `element` should be string type or DOM Element!'
    );

    assert(
      typeof opt_offset === 'number' ||
        typeof opt_offset === 'object' ||
        typeof opt_offset === 'undefined',
      '@param `opt_offset` should be number or Object or undefined!'
    );

    let offsetOpt;
    const idx = ++this.counter;
    const emitter = new TinyEmitter();
    const node = evaluate(element);

    assert(
      isElement(node),
      `Couldn't evaluate (${element}) to a valid DOM node`
    );

    offsetOpt =
      typeof opt_offset === 'number'
        ? { top: opt_offset, bottom: opt_offset }
        : mergeOptions(DEFAULT_OFFSET, opt_offset);

    Base.Internal.watching[idx] = {
      node,
      emitter,
      offset: offsetOpt,
github joeattardi / emoji-button / src / index.js View on Github external
this.options = { ...DEFAULT_OPTIONS, ...options };
    if (!this.options.rootElement) {
      this.options.rootElement = document.body;
    }

    this.i18n = {
      ...i18n,
      ...options.i18n
    };

    this.onDocumentClick = this.onDocumentClick.bind(this);
    this.onDocumentKeydown = this.onDocumentKeydown.bind(this);

    this.events = new Emitter();
    this.publicEvents = new Emitter();
  }
github webcreate / infinite-ajax-scroll / src / infinite-ajax-scroll.js View on Github external
constructor(container, options = {}) {
    Assert.singleElement(container, 'container');

    this.container = $(container)[0];
    this.options = extend({}, defaults, options);
    this.emitter = new Emitter();
    this.scrollContainer = this.options.scrollContainer;

    if (this.options.scrollContainer !== window) {
      Assert.singleElement(this.options.scrollContainer, 'options.scrollContainer');

      this.scrollContainer = $(this.options.scrollContainer)[0];
    }

    this.nextHandler = nextHandler;
    if (typeof this.options.next === 'function') {
      this.nextHandler = this.options.next;
    }

    this.binded = false;
    this.paused = false;
    this.loadOnScroll = this.options.loadOnScroll;
github sndrgb / smoothie / src / hijack.js View on Github external
delete options.el;
        }

        this.options = Object.assign({
            mouseMultiplier: 1,
            touchMultiplier: 2,
            firefoxMultiplier: 15,
            keyStep: 120,
            preventTouch: false,
            unpreventTouchClass: 'hijack-touchmove-allowed',
            limitInertia: false
        }, options);

        if (this.options.limitInertia) this.lethargy = new Lethargy();

        this.emitter = new Emitter();
        this.event = {
            y: 0,
            x: 0,
            deltaX: 0,
            deltaY: 0
        };
        this.touchStartX = null;
        this.touchStartY = null;
        this.bodyTouchAction = null;

        if (this.options.passive !== undefined) {
            this.listenerOptions = { passive: this.options.passive };
        }
    }
github webcreate / infinite-ajax-scroll / dist / infinite-ajax-scroll.es.js View on Github external
var InfiniteAjaxScroll = function InfiniteAjaxScroll(container, options) {
  if ( options === void 0 ) options = {};

  Assert.singleElement(container, 'container');

  this.container = $(container)[0];
  this.options = extend({}, defaults, options);
  this.emitter = new Emitter();
  this.scrollContainer = this.options.scrollContainer;

  if (this.options.scrollContainer !== window) {
    Assert.singleElement(this.options.scrollContainer, 'options.scrollContainer');

    this.scrollContainer = $(this.options.scrollContainer)[0];
  }

  this.nextHandler = nextHandler;
  if (typeof this.options.next === 'function') {
    this.nextHandler = this.options.next;
  }

  this.binded = false;
  this.paused = false;
  this.pageIndex = 0;
github joeattardi / emoji-button / src / index.js View on Github external
this.pickerVisible = false;

    this.options = { ...DEFAULT_OPTIONS, ...options };
    if (!this.options.rootElement) {
      this.options.rootElement = document.body;
    }

    this.i18n = {
      ...i18n,
      ...options.i18n
    };

    this.onDocumentClick = this.onDocumentClick.bind(this);
    this.onDocumentKeydown = this.onDocumentKeydown.bind(this);

    this.events = new Emitter();
    this.publicEvents = new Emitter();
  }

tiny-emitter

A tiny (less than 1k) event emitter library

MIT
Latest version published 5 years ago

Package Health Score

67 / 100
Full package analysis