Skip to content

Commit 442361c

Browse files
committed
docs(blog): improve code examples in conflict resolution article
- Fix data model consistency: use object notation { user: "alice" } - Add client initialization context before resolver registration
1 parent b625671 commit 442361c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

apps/docs-astro/src/content/blog/conflict-resolution-beyond-lww.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ But for the other 10%, it's a disaster.
1919
Imagine two users trying to book the same seat on a flight:
2020

2121
```
22-
User A: book(seat: "A1", user: "alice") → timestamp: 1000
23-
User B: book(seat: "A1", user: "bob") → timestamp: 1001
22+
User A: set("A1", { user: "alice" }) → timestamp: 1000
23+
User B: set("A1", { user: "bob" }) → timestamp: 1001
2424
25-
LWW Result: seat A1 → bob
25+
LWW Result: seat A1 → { user: "bob" }
2626
```
2727

2828
Alice's booking is silently overwritten. No error, no notification, just... gone. She shows up at the airport thinking she has seat A1, only to find Bob sitting there.
@@ -46,6 +46,8 @@ We needed a solution that:
4646
Our solution: **Custom Conflict Resolvers**—server-side functions that intercept every write operation and decide what to do.
4747

4848
```typescript
49+
const resolvers = client.getConflictResolvers();
50+
4951
await resolvers.register('bookings', {
5052
name: 'first-write-wins',
5153
code: `

0 commit comments

Comments
 (0)