-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove State snapshot from StoreSubscriber #8
Comments
I am afraid this cannot be done. There reason is that Reduks engine is much more asynchronous than the original. multiple reduce/dispatch operation can run in parallel, and notification to subscribers happens independently (if yow want take a look at KovenantStore). This is actually a design choice |
Wouldn't that make the change even more compelling? Call site could presume that the state that sent along with argument is current one, while the truth is it isn't. The reason behind is that I update UI by using the argument from the subscriber block. Little did I know that the state has been changed behind my back to something else by dispatching another function. This makes my UI render the out-dated state instead of using the latest version which looks wrong to me. |
If you are using rxJava or simplestore the behavior is what you expect to be. |
So don't be afraid. Anyway I will look into it. Perhaps I need to change the design |
I understand, just want to let you know that I was bitten hard by UI jerking reason is using the state argument from the subscriber block. When I moved to use |
Can you tell me more about what was happening in your UI? I would like to try to understand what was happening |
for reference here is the discussion about it in redux |
In brief: the main reason is to make the methods in Store API, subscribe() and getState() are orthogonal on purpose so if you “override” one in a store enhancer, you don’t need to override the other. |
But, redux.js still using the |
I think we actually have two issues here:
|
About the first issue I agree with you. Just I need to think a bit to make it work with KovenantReduks. |
The problem with porting Redux is that the core API is relatively low level. It is not really useful without adding a lot of other stuff. This is the reason I added other things like Selectors to Reduks core. Then it becomes a little bit opinionated. Not to mention that kotlin and javascript are quite different in many aspects, which forces additional choices that can distance Reduks from the original. It is not easy to strike the right balance |
solved in release 2.0.0b6 |
💛 |
Based on main redux documentation, listener function signature is
subscribe(listener: () => void): Unsubscribe;
https://github.com/reactjs/redux/blob/master/docs/FAQ.md#how-do-i-subscribe-to-only-a-portion-of-the-state-can-i-get-the-dispatched-action-as-part-of-the-subscription
I propose we should match that in other words, we remove the state argument from
StoreSubscriber
From
To
Then it is responsibility of the call site to call
store.state
in order to get current state value.The text was updated successfully, but these errors were encountered: