Closed AndrewSB closed 8 years ago
I don't think "FRP" and "Redux" are exactly interchangeable. I consider Redux to be a unidirectional data flow architecture with a single store, single (main) reducer, and multiple subscribers. FRP as a technique to my understanding is simply the process of reacting to changes in observables with pure functions.
In fact, the two can be complementary, and are already related. Cordux (and ReSwift, on which it is based) implement their own observable streams: store.dispatch
to write to the action stream is roughly equivalent to something like actionStream.on(.next(action))
; store.subscribe(self)
to read from the state stream is roughly equivalent to stateStream.subscribe(onNext: ..)
.
I do not wish users of Cordux to have to include any other third party libraries if they don't wish to, so I left it out of this implementation.
However, if you wished to use an FRP helper library like RxSwift, you could easily bridge the two. You could create an Observable<Action>
stream with a single RxSwift subscriber to dispatch to the store, and create a single Cordux subscriber that would turn states into a new Observable<AppState>
stream.
@ianterrell: meant to say this makes complete sense, I'll let you know if I end up making a helper library that uses RxSwift 👍
Any thoughts on using FRP instead of redux to manage state in cordux apps? Why one might be better than the other? If there was any conversation related to that choice?