react-async-hook
react-async-hook copied to clipboard
Some extra info for onSuccess callback
Hi Sebastien, thanks for adding onSuccess hooks! Just noting a couple things that could improve the usage flexibility.
- often there is a need to know not just the result but also the original params that went into the
executemethod call (there is a workaround possible, but still could be nice to have this) - most of the time we need to ignore onSuccess if the operation/screen is no longer relevant, to not show unexpected toast message/do setState/etc; the former check can be accomodated via the
isCurrentcall (although I am not sure why it needs a call rather than being just a boolean), but the latter needs an is-mounted check, which would be great to pass in as a flag to onSuccess as well
Thanks for your work on this library, cheers!
Hi, Great you like the lib :)
-
there is a result.currentParams returned. If you really need the params of the success/error calls, I'm ok to include this
-
I need it to be a call because you might want to show an error message and dismiss it 2secs later. isCurrent may help you avoid dismissing the wrong error message. I'd be ok to include isMounted into the callback if it helps
I don't have time this week to work on this but if you want feel free to open a PR :)