rivertion 0.1.0-dev.3 copy "rivertion: ^0.1.0-dev.3" to clipboard
rivertion: ^0.1.0-dev.3 copied to clipboard

discontinued
outdated

Extends riverpod by adding the ability to manipulate data via asynchronous mutations / actions.

Rivertion #

Extends riverpod by adding the ability to manipulate data via asynchronous mutations / actions.

Features #

  • Perform asynchronous data mutations
  • Refresh a provider's when mutation complete

Usage #

Define your mutation:

final addTodo = MutationProvider((ref) {
  return MutationBloc((todo) async {
    await Future.delayed(const Duration(seconds: 2));

    // Call api and add a todo
    _todos = [..._todos, todo];
  });
});

Launch your mutation:

final addTodoState = ref.read(addTodo);

ElevatedButton(
  onPressed: addTodoState.isMutating
      ? null
      : () => ref.read(addTodo.bloc).mutate("New Todo!"),
  child: Text('Add Todo'),
),

Additional information #

Refresh a provider

You can refresh a provider when a mutation ends:

final removeTodo = MutationProvider<String, void>((ref) {
  return MutationBloc((todo) async {
    await Future.delayed(const Duration(seconds: 2)); // Api call
  }, onSuccess: (_, __) async {
    await ref.refresh(todos.future);
  });
});
1
likes
0
pub points
23%
popularity

Publisher

unverified uploader

Extends riverpod by adding the ability to manipulate data via asynchronous mutations / actions.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

bloc, mek_data_class, meta, riverbloc, riverpod, rxdart

More

Packages that depend on rivertion