kefirjs / kefir

A Reactive Programming library for JavaScript
https://kefirjs.github.io/kefir/
MIT License
1.87k stars 97 forks source link

React onClick best practices #110

Closed bobfp closed 9 years ago

bobfp commented 9 years ago

I'm using kefir with a new react app I'm working on, and I'm trying to find the best way to handle the onClick events.

I've read all the other issues on here about alternatives to Bus, and I settled on using

var count = Kefir.pool();
clickHandler = count.plug(Kefir.constant(1)); 

But I don't see how this is different from the bus of doom situation. Is there a better way of handling React events?

Thanks,

rpominov commented 9 years ago

You are right, it's not much different from using emitter. But with the interface that React provides for subscribing to events, you have to use something like emitter.

See also https://gitter.im/pozadi/kefir?at=55782a6ff40a067d1c9c0cf9