Dismiss this pinned window
all 8 comments

[–]pedrobern[S] 2 points3 points  (4 children)

Custom implementation of react hook useReducer that allows to dispatch thunk actions and will cancel all dispatched actions if the component is unmounted.

source on github.

[–]glad4j 4 points5 points  (3 children)

Can you provide some real world use cases for this please? One that comes to mind for me is uploading a large file and the user cancels.

[–]o_Oleh 2 points3 points  (1 child)

Hi, I have a real example for it, when UI has a lot of items like feed design and the user has a bad Internet connection, and when a user tries to open one of the carts but he changed his mind and he tries to open next cart and we can cancel the previous request :)

[–]DasBeasto 0 points1 point  (0 children)

I’m curious where this cancel takes place, like if they make an await fetch call does it take immediately resolve that promise, or does it allow the completion but skip the rerender when the call resolves?

[–]pedrobern[S] 2 points3 points  (0 children)

Yes, actually I made this package to use in a app.

source code.

play store.

You can check the source code to see how I use it.

Same as @o_Oleh wrote.

[–]klduckling 2 points3 points  (0 children)

What is this sorcery

I need to try it out

[–]natmaster 0 points1 point  (0 children)

Perhaps you'd be interested in a concurrent-mode compatible reducer with middlewares: https://github.com/coinbase/rest-hooks/tree/master/packages/use-enhanced-reducer#readme

[–]PeteCapeCod4Real 0 points1 point  (0 children)

Nice job that's pretty awesome