bloody-domeventstream
v0.0.0
Published
## install
Downloads
2
Readme
DOM Event stream
install
$ npm install bloody-domeventstream
require
var DOMEventStream = require("bloody-domeventstream")
api
EventStream.createEventStreamAtNode(element, type[, capture=false]) => stream
creates an event stream that receives event objects when events are fired.
var stream = require("bloody-stream")
var articleClickStream = EventStream.createEventStreamAtNode(
document.getElementById("article"),
"click"
)
articleClickStream.on("data", function(eventObject){
console.log("event object :", eventObject)
})
EventStream.removeEventStreamAtNode(element, type[, capture=false]) => didRemove (boolean)
stops listening the given event and ends the stream.
returns a boolean : true
if there was a listener, false
if not.
DOMEventStream.removeEventStreamAtNode(
document.getElementById("article"),
"click"
)
EventStream.filterBySelector(selector) => stream
utility returning a passthrough stream filtering the target by selector.
articleClickStream
.pipe(DOMEventStream.filterBySelector(".js-Button"))
.on("data", function(eventObject){
console.log(eventObject.delegatedTarget)
})
trigger an event
to trigger an event juste use the write
method of the stream.
articleClickStream.write({
target : myTarget,
pageY : 0,
pageX : 0
})