spawn_mutation

Function spawn_mutation 

Source
pub fn spawn_mutation<T, P, V>(
    cx: &mut Context<'_, V>,
    client: &QueryClient,
    mutation: &Mutation<T, P>,
    params: P,
    on_complete: impl FnOnce(&mut V, MutationState<T>, &mut Context<'_, V>) + 'static,
)
where T: Clone + Send + Sync + Debug + 'static, P: Clone + Send + Debug + 'static, V: 'static,
Expand description

Execute a mutation with automatic cache invalidation.

§Example

spawn_mutation(cx, &self.query_client, &create_user_mutation, params, |this, state, cx| {
    match state {
        MutationState::Success(user) => {
            this.show_success("User created!");
        }
        MutationState::Error(e) => {
            this.show_error(e.to_string());
        }
        _ => {}
    }
    cx.notify();
});