intendednull / yewdux

Ergonomic state management for Yew applications
https://intendednull.github.io/yewdux/
Apache License 2.0
322 stars 31 forks source link

Yewdux hooks #4

Closed lukechu10 closed 3 years ago

lukechu10 commented 3 years ago

This PR adds hooks in a seperate yewdux-functional crate for usage with function components in Yew.

This is still WIP because I get an error when calling a callback The Id of the handler: 1, while present in the slab, is not associated with a callback. even though all functionality is properly working.

Final API:

lukechu10 commented 3 years ago

Question How would a use_selector hook work? The Dispatch returns an Rc so it would be impossible to implement without cloning the result of the selector.

lukechu10 commented 3 years ago

It seems to be working as expected! Here's a demo. I still need to add some unit tests.

Open in Gitpod

lukechu10 commented 3 years ago

Sorry for the long wait. Just BTW I haven't tested any of this yet so none of it might work. Edit: It doesn't work yet.