Skip to content

Inheritance with code gen (specificly AsyncNotifier) #3827

Answered by MuKhAlm
MuKhAlm asked this question in Q&A
Discussion options

You must be logged in to vote

For anyone curios, here's my solution: (Note thanks to @rrousselGit for the advice)

/// Provides basic structure for Riverpod
/// mutation controllers
///
/// Call `performMutationAction` to perform a mutation action.
///
/// Call `onBuild` inside `build`.
///
/// Assuming your controllers use AutoDispose (still no idea how to make it work with both options)
mixin MutationControllerMixin on AutoDisposeAsyncNotifier {

  /// Executed during [build]
  Future<void> onBuild() async {
    disposedStatusMount(ref);
  }

  /// Performs a mutation action
  ///
  /// Handles success and error messages,
  /// state updates, etc.
  /// 
  /// Sets state to value returned by [mutationAction].
  /// S…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@MuKhAlm
Comment options

@MuKhAlm
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by MuKhAlm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants