(
id: string,
getKey: (item: T) => string | number,
)
| 6297 | |
| 6298 | describe(`many sibling toArray includes with chained derived collections`, () => { |
| 6299 | function createSyncCollection<T extends object>( |
| 6300 | id: string, |
| 6301 | getKey: (item: T) => string | number, |
| 6302 | ) { |
| 6303 | let syncBegin: () => void |
| 6304 | let syncWrite: (msg: { type: string; value: T }) => void |
| 6305 | let syncCommit: () => void |
| 6306 | |
| 6307 | const collection = createCollection<T>({ |
| 6308 | id, |
| 6309 | getKey, |
| 6310 | sync: { |
| 6311 | sync: (params: any) => { |
| 6312 | syncBegin = params.begin |
| 6313 | syncWrite = params.write |
| 6314 | syncCommit = params.commit |
| 6315 | params.markReady() |
| 6316 | return () => {} |
| 6317 | }, |
| 6318 | } as SyncConfig<T>, |
| 6319 | startSync: true, |
| 6320 | gcTime: 0, |
| 6321 | }) |
| 6322 | |
| 6323 | return { |
| 6324 | collection, |
| 6325 | insert(value: T) { |
| 6326 | syncBegin!() |
| 6327 | syncWrite!({ type: `insert`, value }) |
| 6328 | syncCommit!() |
| 6329 | }, |
| 6330 | } |
| 6331 | } |
| 6332 | |
| 6333 | const TIMELINE_KEY = `timeline` |
| 6334 |
no test coverage detected