[Suggestion] Convenience methods for MutationState (check for loading, success, error)
Is your feature request related to a problem? Please describe. It's not a problem per se but eliminates the need of defining an extension. Also can be a first step making MutationState similar in usage to AsyncValue
Describe the solution you'd like Add the following methods to the MutationState class
bool get isLoading => this is PendingMutation;
bool get isSuccess => this is SuccessMutation;
bool get hasError => this is ErrorMutation;
The main issue is, those don't upcast the type.
You can't do ``dart if (state.isSuccess) state.value.doSomething()
in 90% of cases in my project I don't need the value itself. E.g. if I want to show a toast on successful mutation, or an error (without specifying the error).
isLoading I also use on all kinds of buttons all the time and writing isLoading: mutation.state is PendingMutation just feels not riverpod-y :)
I'll most definitely changes codegen mutations a little bit, to support non-codegen mutations anyway
I also wanted to add that in the brief time that I worked with mutations, I already fell into a trap of writing mutation is PendingMutation instead of mutation.state a couple of times.
Btw mutations are a delight to work with. I've been busy rewriting and testing on one of my projects the whole day and it's a blast.
Great suggestion. This further aligns MutationState with AsyncValue.