Closed intendednull closed 10 months ago
I just went by this PR and I really like it and would also help me for specific cases. I could use them instead of the yew OOTB use_store hooks, which unfortunately have no reducer functions....
Ebenso I like the new feature I'm strongly argue to not change the actual api for the Dispatcher. This would break my code at 300+ places... I mean this function:
let dispatch = Dispatch::<Counter>::new(&cx);
I would rather propose to keep the new function as it is and have an additional function like this:
let dispatch = Dispatch::<Counter>::ctx(&cx);
I also don't understand the benefit of an App vs Thread context. But this is definitely on me.
I hope, this feedback helps :)
@Roba1993 thanks for the feedback!
I like the new feature I'm strongly argue to not change the actual api for the Dispatcher. This would break my code at 300+ places...
Hopefully you can refactor easily with a little regex magic. We aren't 1.0 yet, so breaking changes are to be expected, and shouldn't get in the way of improving the API.
I think this new naming scheme makes it super clear to the user when exactly they are accessing global context. It's a topic that may introduce confusion to newcomers, and so vitally important we make it as easy to understand as possible.
Hopefully you can refactor easily with a little regex magic. We aren't 1.0 yet, so breaking changes are to be expected, and shouldn't get in the way of improving the API.
I think this new naming scheme makes it super clear to the user when exactly they are accessing global context. It's a topic that may introduce confusion to newcomers, and so vitally important we make it as easy to understand as possible.
Yes, I will be able to do this 😄
Primarily important for SSR support, containing state to the scope of the app, instead of the thread.
For a basic example, you can now create a local context for your dispatch:
Changes to one context are not reflected in any others:
The default context for a dispatch is global (thread local).
A root component is now available to provide context that is scoped to the app:
Hooks will detect the context provided by
YewduxRoot
. If no root is provided, it uses global by default.