Reputation: 1
pixijs use eventemitter3 for handler sprites events. for example
sprite.on('mousedown', onDown),
i am wondering how to make a driver in order to handlering events listening sprites.can any one show me some point?
Upvotes: 0
Views: 269
Reputation: 139
const mouseDown$ = Rx.Observable.create((observer) => {
sprite.on('mousedown', e => observer.onNext(e));
return () => {
//unsubscribe event here
}
})
https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/create.md
Upvotes: 0
Reputation: 2555
I don't think you need a driver specifically for EventEmitter.
Both xstream and rxjs (don't know about the other stream libraries cyclejs supports) support dom events and eventemitter events with the fromEvent
method. With that you can build streams that emit values when the event triggers on the specified target.
check out the xstream documentation for an example, rxjs is no different.
Upvotes: 0