Giter VIP home page Giter VIP logo

estate's Introduction

estate

Build Status

aggregate multiple event emitter events + data into a readable stream of state objects.

var es = estate()
  , ee1 = new EE
  , ee2 = new EE

es.listen(ee1, 'thing', ['one', 'two'])
  .listen(ee2, 'data', ['two', 'three', 'four'])

ee1.emit('thing', 1, 2)

es.once('data', function(state) {
  // state will be === {
  //   one: 1
  //   two: 10
  //   three: 20
  //   four: 30
  // }
})

ee2.emit('data', 10, 20, 30)

es.once('data', function(state) {
  // one and two will be cleared!
})

ee1.emit('thing') // since "one" and "two" are undefined, it'll clear those states

or in terms of Streams2

es.on('readable', function() {
  var state = es.read()
})

or just pipe:

es.pipe(debounce).pipe(make_xhr).pipe($(el))

API

es.listen(emitter, eventName, ['list', 'of', 'bindings']) -> es

listen to an emitter on eventName. when that emitter emits that event name, it will update the state object. The state object will expose the current state by .read().

estate will buffer only the most recent state. This means its information is always up to date-- if you only read() when you are ready for more data, (or have the proper back pressure if your using it in flowing mode), debouncing is not required.

License

MIT

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.