(numItems: number)
| 37 | } |
| 38 | |
| 39 | async function clearItems(numItems: number) { |
| 40 | const itemsStream = getShapeStream(itemShape()) |
| 41 | |
| 42 | // Match the delete |
| 43 | const findUpdatePromise = |
| 44 | numItems > 0 |
| 45 | ? matchStream({ |
| 46 | stream: itemsStream, |
| 47 | operations: [`delete`], |
| 48 | // First delete will match |
| 49 | matchFn: () => true, |
| 50 | }) |
| 51 | : Promise.resolve() |
| 52 | |
| 53 | // Delete all items |
| 54 | const fetchPromise = fetch(itemsUrl, { method: `DELETE` }) |
| 55 | |
| 56 | return await Promise.all([findUpdatePromise, fetchPromise]) |
| 57 | } |
| 58 | |
| 59 | export const Example = () => { |
| 60 | const queryClient = useQueryClient() |
no test coverage detected