You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/fragments/lib/datastore/js/conflict.mdx
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,42 @@ Finally you can configure the number of records to sync as an upper bound on ite
6
6
7
7
The code below illustrates a conflict resolution handler for the `Post` model that retries a mutation with the same title, but the most recent remote data for all other fields. The conflict resolution handler discards conflicts for all other models (by returning the `DISCARD` symbol imported from `@aws-amplify/datastore`).
8
8
9
+
<BlockSwitcher>
10
+
<Blockname="TypeScript">
11
+
12
+
```ts
13
+
import {
14
+
DISCARD,
15
+
PersistentModelConstructor,
16
+
} from"@aws-amplify/datastore";
17
+
18
+
DataStore.configure({
19
+
errorHandler: (error) => {
20
+
console.warn("Unrecoverable error", { error });
21
+
},
22
+
conflictHandler: async (data) => {
23
+
// Example conflict handler
24
+
if (data.modelConstructorasPersistentModelConstructor<Todo> === Todo) {
0 commit comments