Closed eudaimos closed 8 years ago
I agree with that. Repo should have collaborators.
Also
observableFromStore
should have dispose
.Document what other packages are necessary ( rx-react ?)
I don't think rx-react is necessary
or useful ( recompose
rx-recompose
should be more useful IMO
Our team is working on our own (closed source) implementation of rx bindings for redux but it will be much better if we could use this package. But we want it to be maintained more actively.
Hi! Sorry I've let this project go by the wayside. I've gotten to the state recently where I have too many projects and not enough time to maintain them, so unless I'm using them actively they do indeed fall by the wayside.
I'm absolutely happy to open this up to collaborators. I've just added you as one :)
In addition to the sensible steps you've listed like pushing the changes to the middleware API, my suggestion is that createConnector()
should be removed in favor of using rx-recompose (or similar) directly. That project + observableFromStore()
+ .flatMap()
gives you all the power you need, and would allow the library to be view framework agnostic.
Btw what's your npm username? I'll add you there as well
@chicoxyzzy I've added you as well
@acdlite thank you. I'll try my best on it. My npm username is same as GitHub's one
@chicoxyzzy Added on npm
@acdlite thank you for such a quick turnaround (which confirms my sending this before driving home :)
My npm username is also the same as my Github eudaimos
@acdlite per your comment above, can you please elaborate with a simple example (or more if you have time) for what you mean by using rx-recompose + observableFromStore(…)
+ .flatMap(…)
aka .selectMany(…) in place of createConnector()
Do you mean something like:
import Redux from 'redux';
import { Observable } from 'rx';
import { observableFromStore } from 'redux-rx';
import { observeProps } from 'rx-recompose';
const storeState$ = observableFromStore(store);
const fooState$ = storeState$.map(state => state.fooKey).distinctUntilChanged(fstate => fstate.id);
const FooCtor = observeProps(props$ => {
return Observable.combineLatest(props$, fooState$, (props, fooState) => Object.assign(props, fooState);
});
const Foo = FooCtor(<div>…</div>);
.flatMap(…)
above and could use some assistance on thatObject.assign(…)
Also per @chicoxyzzy 's comment, would this necessitate having a .dispose()
method for observableFromStore()
?
Yeah, if you do it like that you don't need .flatMap()
. I was thinking about a situation like this, where you grab the store from the stream of props:
const enhance = compose(
getContext({ store: PropTypes.object }),
observeProps(props$ => {
const storeState$ = props$.flatMap(props => observableFromStore(props.store))
// ...
})
)
observableFromStore()
already supports disposal because the function passed to Observable.create()
returns an unsubscribe function. Admittedly, this isn't exactly clear from the source, but here's the longer version:
export default function observableFromStore(store) {
return Observable.create(observer => {
const unsubscribe = store.subscribe(() => observer.onNext(store.getState()));
// By returning unsubscribe, the observable can be disposed
return unsubscribe;
});
}
Oh, I've missed that there is no curly braces there. @eudaimos I think we should create roadmap first to make it clear what we want redux-rx to be and move iterativly
thanks again @acdlite
I figured the way I was doing it I would create the storeState$
once using observableFromStore(…)
and then pass it around like that allowing whatever to create their own filters from it to handle the state that individual component or other thing care about. That's how I would've done it with Rx in .NET at least.
Are you advocating that it's better to isolate (usually better) within single component code and have multiple Observable
s created against the store or just clarifying your example?
@chicoxyzzy good idea on the Roadmap - I'll start a new issue for it
@acdlite aside from more clarification to my last question above ^^ - were you able to add me to NPM?
@acdlite
I greatly appreciate what you've done to get this started and I'm sure it came out of a passion for using RxJs with Redux/React for yourself. However, there are several simple clean up tasks that are going by the wayside due to how busy you are and it's preventing those interested from adopting a truly Reactive application from using your great and simple library.
My one request is that you open this up to maintenance by more people so that the following items can get done:
npm install redux-rx
installs version0.5.0
but the latest Release for the repo is tagged as0.4.0
, neither of which have the fix for the Middleware APIimport
statements at the top and an example of how to use it withreact-redux
, specifically:createConnector
example by showing how it is used with theTodo
componentobservableMiddleware
doesn't even includeobservableMiddleware
in the examplerx
andredux
peer dependenciesPersonally, I'd be more than happy to perform these activities but at the moment I'm struggling with learning how to use this with my own new implementation of React+Redux Universal so I certainly can't provide help with examples
Thanks again!