Coder Social home page Coder Social logo

aggregating-emitter's Introduction

aggregating-emitter

Provides a mixing which enhances component-emitter. One can stop the normal emitting of events. All emit calls are recorded and will be executed when emitting events is started again. For each event type only the most recent recorded emit will be executed.

API

#stopEvents()

Called to stop normal emitting of events. Events will be recorded and execution on the next call to continueEvents.

#continueEvents()

Called to execute the emits which were recorded since the last call to stopEvents.

Example

function MyModel() {}

MyModel.prototype.setValue = function(value) {
    this.value = value;
    this.emit('chage', value);
}

// call the mixin
AggregatingEmitter(MyModel);

m = new MyModel();

// immediately emits the change event
m.setValue(10);

MyModel.stopEvents()

// no change events emitted
m.setValue(20);
m.setValue(30);

// emits a single change event with value 30
MyModel.continueEvents();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.