subscribeWithSelector is unnecessarily complicated
#3317
Unanswered
kettanaito
asked this question in
Ideas
Replies: 3 comments 18 replies
-
|
Thanks for raising it up. Some history:
Yes, I like your proposition. It's no longer middleware right? That's what I mean with the easier way.
|
Beta Was this translation helpful? Give feedback.
1 reply
-
|
@kettanaito lmk if you need some help, I'd be happy to help to deprecated |
Beta Was this translation helpful? Give feedback.
16 replies
-
|
@kettanaito |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
The current approach to
subscribeWithSelectoris unnecessarily complicated in a sense that it requires you to wrap your entire store for no apparent benefit (based on the current implementation). All it does is implements its ownsubscribefunction on top of thestore.subscribe.The problem with this approach is that:
subscribesincesubscribeWithSelectoralso creates the store. It mixed multiple unrelated concerns whereas it should only be focused on helping the user to subscribe to a particular slice of the state.Proposed solution
The current implementation of the function can be rewritten to accept any store:
The benefit of this change is that now I can subscribe to any store anywhere I want to:
I don't need to wrap my stores into this. It becomes what it is supposed to be: a way to subscribe to a slice of the state.
Let me know if this makes sense to you. I'm happy to open a pull request and help ship this. Thanks.
Beta Was this translation helpful? Give feedback.
All reactions