2.1.0 • Published 8 years ago

weak-bubble v2.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

weak-bubble Build Status

Bubble weakmap-events up without explicit re-broadcasting

Install

$ npm install --save weak-bubble

Usage

var event = require('weakmap-event')()
var bubble = require('weak-bubble')
var state = {
  foo: {}
}

var listen = bubble({foo: event.listen})
listen(state, function (data) {
  //=> 'DATA!'
})
event.broadcast(state.foo, 'DATA!')

API

bubble(listeners, [transform]) -> function

listeners

Required
Type: object

An object where the keys represent keys in your object and the values are the listen functions from a weakmap-event.

transform

Type: function
Arguments: state, data

An optional function called with the state and event data. By default, the event data is forwarded up. By passing in a function, you can add or remove properties or return entirely different data.

If you return false, the listeners will not be called.

License

MIT © Ben Drucker

2.1.0

8 years ago

2.0.0

8 years ago

1.1.0

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago