Skip to content

bendrucker/weak-bubble

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

weak-bubble Build Status Greenkeeper badge

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

About

Bubble weakmap-events up without explicit re-broadcasting

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •