Open History to see the last commit
1---
2id: UseAsyncQueuedState
3title: UseAsyncQueuedState
4---
5
6Defined in: [packages/ember-pacer/src/async-queuer/useAsyncQueuedState.ts:52](https://github.com/TanStack/pacer/blob/main/packages/ember-pacer/src/async-queuer/useAsyncQueuedState.ts#L52)
7
8Exposes pending queue items together with the queue that processes them.
9
10Retains accepted items until processing. Ordering, capacity, wait, and started options follow the underlying queue.
11
12## Return value
13
14Yields the queue instance. Read pending items from queue.state.items and enqueue with queue.addItem().
15
16## State and ownership
17
18Items 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.
19
20Invoke in a Glimmer template. Positional arguments provide the callback or value and optional selector. Named arguments provide options. Removing the invocation runs cleanup.
21Tracked named arguments refresh options after rendering. Local options override provider defaults without replacing the utility or its pending work.
22onUnmount replaces default cleanup and receives the utility instance. A custom callback must perform every needed cancel, stop, or abort action.
23
24## Example
25
26```gts
27import { on } from '@ember/modifier'
28import { fn } from '@ember/helper'
29import { useAsyncQueuedState } from '@tanstack/ember-pacer'
30
31// Inside a component template:
32<template>
33{{#let (useAsyncQueuedState @process wait=500) as |queue|}}
34 <button {{on "click" (fn queue.addItem 1)}}>Add</button>
35 <output>{{queue.state.items.length}}</output>
36{{/let}}
37</template>
38```
39
40## See
41
42useAsyncQueuer
43
44## Extends
45
46- `default`\<\{
47 `Args`: \{
48 `Named`: [`EmberAsyncQueuerOptions`](../interfaces/EmberAsyncQueuerOptions.md)\<`TValue`, `TSelected`\>;
49 `Positional`: \| \[(`item`) => `Promise`\<`any`\>\]
50 \| \[(`item`) => `Promise`\<`any`\>, (`state`) => `TSelected`\];
51 \};
52 `Return`: [`EmberAsyncQueuer`](../interfaces/EmberAsyncQueuer.md)\<`TValue`, `TSelected`\>;
53\}\>
54
55## Type Parameters
56
57### TValue
58
59`TValue`
60
61### TSelected
62
63`TSelected` *extends* `Pick`\<`AsyncQueuerState`\<`TValue`\>, `"items"`\> = `Pick`\<`AsyncQueuerState`\<`TValue`\>, `"items"`\>
64
65## Constructors
66
67### Constructor
68
69```ts
70new UseAsyncQueuedState<TValue, TSelected>(owner?): UseAsyncQueuedState;
71```
72
73Defined in: node\_modules/.pnpm/ember-source@7.3.0\_@glimmer+component@2.1.1\_supports-color@7.2.0\_\_supports-color@7.2.0/node\_modules/ember-source/types/stable/@ember/object/index.d.ts:28
74
75#### Parameters
76
77##### owner?
78
79`Owner`
80
81#### Returns
82
83`UseAsyncQueuedState`
84
85#### Inherited from
86
87```ts
88Helper<{
89 Args: {
90 Positional:
91 | [fn: (item: TValue) => Promise<any>]
92 | [
93 fn: (item: TValue) => Promise<any>,
94 selector: (state: AsyncQueuerState<TValue>) => TSelected,
95 ]
96 Named: EmberAsyncQueuerOptions<TValue, TSelected>
97 }
98 Return: EmberAsyncQueuer<TValue, TSelected>
99}>.constructor
100```
101
102## Methods
103
104### compute()
105
106```ts
107compute(positional, options): EmberAsyncQueuer<TValue, TSelected>;
108```
109
110Defined in: [packages/ember-pacer/src/async-queuer/useAsyncQueuedState.ts:78](https://github.com/TanStack/pacer/blob/main/packages/ember-pacer/src/async-queuer/useAsyncQueuedState.ts#L78)
111
112Override this function when writing a class-based helper.
113
114#### Parameters
115
116##### positional
117
118\[(`item`) => `Promise`\<`any`\>, (`state`) => `TSelected`\]
119
120The positional arguments to the helper
121
122##### options
123
124[`EmberAsyncQueuerOptions`](../interfaces/EmberAsyncQueuerOptions.md)\<`TValue`, `TSelected`\>
125
126#### Returns
127
128[`EmberAsyncQueuer`](../interfaces/EmberAsyncQueuer.md)\<`TValue`, `TSelected`\>
129
130#### Method
131
132compute
133
134#### Since
135
1361.13.0
137
138#### Overrides
139
140```ts
141Helper.compute
142```