Open History to see the last commit
1---
2id: createQueuedSignal
3title: createQueuedSignal
4---
5
6```ts
7function createQueuedSignal<TValue, TSelected>(
8 fn,
9 options?,
10 selector?): [() => TValue[], (item, position?, runOnItemsChange?) => boolean, SvelteQueuer<TValue, TSelected>];
11```
12
13Defined in: [packages/svelte-pacer/src/queuer/createQueuedSignal.ts:34](https://github.com/TanStack/pacer/blob/main/packages/svelte-pacer/src/queuer/createQueuedSignal.ts#L34)
14
15Exposes pending queue items together with the queue that processes them.
16
17Retains accepted items until processing. Ordering, capacity, wait, and started options follow the underlying queue.
18
19## Return value
20
21Returns [itemsAccessor, addItem, queue]. Call itemsAccessor() to read pending items.
22
23## State and ownership
24
25Items are selected by default. A custom selector must retain items and may add other state fields. The returned collection contains pending items; async active items are separate.
26
27Call during component initialization. Component destruction removes effects and subscriptions and runs utility cleanup.
28Options accept an object with top-level getters or an options factory. Function-valued core options remain callbacks. Local options override provider defaults without replacing the utility or its pending work.
29onUnmount replaces default cleanup and receives the utility instance. A custom callback must perform every needed cancel, stop, or abort action.
30
31## Type Parameters
32
33### TValue
34
35`TValue`
36
37### TSelected
38
39`TSelected` *extends* `Pick`\<`QueuerState`\<`TValue`\>, `"items"`\> = `Pick`\<`QueuerState`\<`TValue`\>, `"items"`\>
40
41## Parameters
42
43### fn
44
45(`item`) => `void`
46
47### options?
48
49[`SveltePacerOptions`](../type-aliases/SveltePacerOptions.md)\<[`SvelteQueuerOptions`](../interfaces/SvelteQueuerOptions.md)\<`TValue`, `TSelected`\>\> = `{}`
50
51### selector?
52
53(`state`) => `TSelected`
54
55## Returns
56
57\[() => `TValue`[], (`item`, `position?`, `runOnItemsChange?`) => `boolean`, [`SvelteQueuer`](../interfaces/SvelteQueuer.md)\<`TValue`, `TSelected`\>\]
58
59## Example
60
61```ts
62import { createQueuedSignal } from '@tanstack/svelte-pacer'
63
64// During component initialization:
65const [items, addItem, queue] = createQueuedSignal((item: number) => { console.log(item) }, { wait: 500 })
66addItem(1)
67console.log(items())
68```
69
70## See
71
72createQueuer