redux-effects / redux-effects

494 stars 12 forks source link

Multiple Results i.e. Observable? #5

Open ronag opened 8 years ago

ronag commented 8 years ago

Would be interesting to add support for a RxJS based streams instead of steps.

In particular, in our application we want to fetch a list of items, and instead of getting the entire list in a large success call we would prefer something like onNext, onError, onCompleted.

Any thoughts on that?

ashaffer commented 8 years ago

So, redux-effects itself is just a composition strategy for the other effect middleware. redux-effects-events for instance binds event handlers, which obviously don't fit well into the steps model.

Your particular middleware is totally free to just accept its own lambda that it executes in response to something happening in the environment. I would recommend using steps for either your onCompleted event, or for returning a value that is necessary to cancel the process if you have such a thing.

It might be interesting to come up with a general pattern for handling this style of listener though. It could be totally independent of redux-effects. A redux-observable that handles returned observables would be interesting.

joshrtay commented 8 years ago

@ronag redux-observable would be a cool thing to implement. Take a look at redux-gen for an example on how to do that. It's also possible that redux-gen would work for your use case.