MCPcopy Create free account
hub / github.com/TanStack/query / seedCacheOnlyTodo

Method seedCacheOnlyTodo

examples/lit/basic/src/main.ts:110–136  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

108 }
109
110 private seedCacheOnlyTodo(): void {
111 this.cacheSeedCount += 1
112
113 const seedTodo: Todo = {
114 id: 10000 + this.cacheSeedCount,
115 title: `Seeded cache todo ${this.cacheSeedCount}`,
116 }
117
118 demoQueryClient.setQueryData<TodosResponse>(
119 todosQueries.list().queryKey,
120 (existing) => {
121 if (!existing) {
122 return {
123 items: [seedTodo],
124 requestCount: 0,
125 source: 'cache',
126 }
127 }
128
129 return {
130 items: [...existing.items, seedTodo],
131 requestCount: existing.requestCount,
132 source: 'cache',
133 }
134 },
135 )
136 }
137
138 private forceNextFetchFailure(): void {
139 failNextFetchRequest()

Callers 1

renderMethod · 0.95

Calls 1

setQueryDataMethod · 0.45

Tested by

no test coverage detected