0

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?

蓝梓文
  • 1
  • 1

2 Answers2

0

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.

alebianco
  • 2,475
  • 18
  • 25
0
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