Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion docs/docs/mutations.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ httpMutation({

### Callbacks

In the mutation: _optional_ `onSuccess` and `onError` callbacks
In the mutation: _optional_ `onSuccess` and `onError` callbacks.

The callbacks are called with two parameters:

1. The result of the mutation (`onSuccess`) or the error (`onError`)
2. The parameter passed when calling the mutation

```ts
({
Expand All @@ -159,6 +164,14 @@ In the mutation: _optional_ `onSuccess` and `onError` callbacks
console.error('Error occurred:', error);
},
});

// using the passed parameter
({
onSuccess: (_result, params) => {
// after successful deletion
store.listResource.set(store.listResource.value().filter((item) => item.id !== params.id));
},
});
```

### Flattening operators
Expand Down