package
> Associate [geval](https://github.com/Raynos/geval) events with a given object.
npm install weakmap-eventGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Associate geval events with a given object.
Adapted from code in Mercury's examples.
$ npm install --save weakmap-eventvar WeakmapEvent = require('weakmap-event')
var onClick = WeakmapEvent()
var obj1 = {}
var obj2 = {}
onClick.listen(obj1, function(data) {
assert.equal(data, 'hello')
})
onClick.listen(obj2, function(data) {
assert.equal(data, 'goodbye')
})
onClick.broadcast(obj1, 'hello')
onClick.broadcast(obj2, 'goodbye')WeakmapEvent() -> eventCreates a new weak-mapped event interface.
event.broadcast(obj, value) -> undefinedBroadcasts the value for listeners mapped to the object
Required
Type: object
The object to limit the broadcast to. Listeners on other objects will not be called.
Required
Type: any
The value to broadcast to matched listeners.
event.listen(obj, listener) -> functionListen on values emitted for a given object. Returns an unlisten function that will disable the listener when called.
Required
Type: object
The object to listen on.
Required
Type: function
Arguments: value
A listener function to be called when a value is broadcasted matching the object.
event.listen.toHash(observable, listener) -> undefinedListen on an observable hash.
Required
Type: function
An observable hash like observ-struct or observ-varhash.
Required
Type: function
Arguments: value
A listener function to be called when a value is broadcasted matching a value from within the hash.
event.listen.toArray(observable, listener) -> undefinedListen on an observable array.
Required
Type: function
An observable array from observ-array.
Required
Type: function
Arguments: value
A listener function to be called when a value is broadcasted matching a value from within the array.
MIT © Eaze Solutions
andytjoslin
andrewtjoslin@gmail.com
Estimated unpacked size across 6 packages.
9.6 kB
Includes dependencies.
4 direct dependencies.