Skip to content
Source
Sign inSign up
fuko/trytanstackdb.com
Open History to see the last commit

todoItemsSync.ts

30 lines670 Bytes

1import {
2 createCollection,
3 localOnlyCollectionOptions,
4} from "@tanstack/react-db";
5​
6export const TODO_ITEMS_SYNC_STATE_ID = "todo-items-sync-state";
7​
8export type TodoItemsSyncState = {
9 id: string;
10 unsyncedItemIds: string[];
11 inFlightItemIds: string[];
12 failedItemIds: string[];
13};
14​
15const initialTodoItemsSyncState: TodoItemsSyncState[] = [
16 {
17 id: TODO_ITEMS_SYNC_STATE_ID,
18 unsyncedItemIds: [],
19 inFlightItemIds: [],
20 failedItemIds: [],
21 },
22];
23​
24export const todoItemsSyncCollection = createCollection(
25 localOnlyCollectionOptions({
26 id: "todo-items-sync",
27 getKey: (item) => item.id,
28 initialData: initialTodoItemsSyncState,
29 }),
30);