-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Add isSuccess, isLoading etc to useAction return object #61
Comments
FYI - I'd be happy to raise a PR if there is an appetite for this. |
Hi @John-Dennehy, next-safe-action v3 actually returned an object with This specific change has been already discussed in this issue, and in this comment I explained why I made it and a possible solution to avoid repeating code, defining simple util functions for the scope. Please let me know if there's anything else I can help you with, thank you. |
Sorry for missing that. That is a shame really. |
No worries! By the way, we could export those utility functions from the library itself, but I'm not sure if this is the right thing to do, not everybody will use them, and defining them in one place is quite simple already. What do you think? |
Sometimes it's useful and more elegant to check the action status using a function instead of string equality. This commit exports util functions to do that, while ensuring the same discriminated behavior that the single `status` property provides to the user, thanks to TypeScript's type predicates feature. re #61, re #37
Action status utility functions implemented in |
Are you using the latest version of this library?
Is there an existing issue for this?
Suggest an idea
While
status
already exists, I find myself needing to creating the same additional "boiler-plate" code around the status string value every time I use useAction; specifically creating boolean variables such asisLoading
for button state.While not a high priority, it would be nice if the response object was a more similar to projects like tanstack/react-query that include both the
status
string and boolean variables like:I imagine any accepted change would need to be applied to useOptimisticAction too.
Additional context
No response
The text was updated successfully, but these errors were encountered: