Skip to content

Commit 839310e

Browse files
committed
refactor: queuers instead of plain queue, new queue function
1 parent 6e50297 commit 839310e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1099
-2314
lines changed

docs/config.json

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,6 @@
323323
"defaultCollapsed": true,
324324
"label": "Queue API Reference",
325325
"children": [
326-
{
327-
"label": "QueueOptions",
328-
"to": "reference/interfaces/queueoptions"
329-
},
330326
{
331327
"label": "QueuerOptions",
332328
"to": "reference/interfaces/queueroptions"
@@ -335,10 +331,6 @@
335331
"label": "AsyncQueuerOptions",
336332
"to": "reference/interfaces/asyncqueueroptions"
337333
},
338-
{
339-
"label": "Queue",
340-
"to": "reference/classes/queue"
341-
},
342334
{
343335
"label": "Queuer",
344336
"to": "reference/classes/queuer"
@@ -352,14 +344,6 @@
352344
{
353345
"label": "react",
354346
"children": [
355-
{
356-
"label": "useQueue",
357-
"to": "framework/react/reference/functions/usequeue"
358-
},
359-
{
360-
"label": "useQueueState",
361-
"to": "framework/react/reference/functions/usequeuestate"
362-
},
363347
{
364348
"label": "useQueuer",
365349
"to": "framework/react/reference/functions/usequeuer"
@@ -387,14 +371,6 @@
387371
"label": "queue",
388372
"to": "framework/react/examples/queue"
389373
},
390-
{
391-
"label": "useQueue",
392-
"to": "framework/react/examples/useQueue"
393-
},
394-
{
395-
"label": "useQueueState",
396-
"to": "framework/react/examples/useQueueState"
397-
},
398374
{
399375
"label": "useQueuer",
400376
"to": "framework/react/examples/useQueuer"

docs/framework/react/reference/functions/useasyncqueuer.md

Lines changed: 20 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ The hook returns an object containing methods to:
5151
addItem: (fn, position?) => Promise<TValue>;
5252
```
5353
54-
Adds a task to the queue
54+
Adds a task to the queuer
5555
5656
#### Parameters
5757
5858
##### fn
5959
60-
() => `TValue` \| `Promise`\<`TValue`\>
60+
() => `Promise`\<`TValue`\>
6161
6262
##### position?
6363
@@ -73,7 +73,7 @@ Adds a task to the queue
7373
clear: () => void;
7474
```
7575
76-
Removes all items from the queue
76+
Removes all items from the queuer
7777
7878
#### Returns
7979
@@ -82,38 +82,34 @@ Removes all items from the queue
8282
### getActiveItems()
8383
8484
```ts
85-
getActiveItems: () => () => Promise<any>[];
85+
getActiveItems: () => () => Promise<TValue>[];
8686
```
8787
8888
Returns the active items
8989
9090
#### Returns
9191
92-
() => `Promise`\<`any`\>[]
93-
94-
The active items
92+
() => `Promise`\<`TValue`\>[]
9593
9694
### getAllItems()
9795
9896
```ts
99-
getAllItems: () => () => Promise<any>[];
97+
getAllItems: () => () => Promise<TValue>[];
10098
```
10199
102-
Returns all items (active and pending)
100+
Returns a copy of all items in the queuer
103101
104102
#### Returns
105103
106-
() => `Promise`\<`any`\>[]
107-
108-
All items
104+
() => `Promise`\<`TValue`\>[]
109105
110106
### getExecutionCount()
111107
112108
```ts
113109
getExecutionCount: () => number;
114110
```
115111
116-
Returns the number of items that have been removed from the queue
112+
Returns the number of items that have been removed from the queuer
117113
118114
#### Returns
119115
@@ -125,27 +121,18 @@ Returns the number of items that have been removed from the queue
125121
getNextItem: (position?) => undefined | () => Promise<TValue>;
126122
```
127123
128-
Removes and returns an item from the queue using shift (default) or pop
124+
Removes and returns an item from the queuer
129125
130126
#### Parameters
131127
132128
##### position?
133129
134-
`QueuePosition`
130+
`"front"` | `"back"`
135131
136132
#### Returns
137133
138134
`undefined` \| () => `Promise`\<`TValue`\>
139135
140-
#### Example
141-
142-
```ts
143-
// Standard FIFO queue
144-
queue.getNextItem()
145-
// Stack-like behavior (LIFO)
146-
queue.getNextItem('back')
147-
```
148-
149136
### getPendingItems()
150137
151138
```ts
@@ -158,15 +145,13 @@ Returns the pending items
158145
159146
() => `Promise`\<`TValue`\>[]
160147
161-
The pending items
162-
163148
### isEmpty()
164149
165150
```ts
166151
isEmpty: () => boolean;
167152
```
168153
169-
Returns true if the queue is empty
154+
Returns true if the queuer is empty
170155
171156
#### Returns
172157
@@ -178,7 +163,7 @@ Returns true if the queue is empty
178163
isFull: () => boolean;
179164
```
180165
181-
Returns true if the queue is full
166+
Returns true if the queuer is full
182167
183168
#### Returns
184169
@@ -190,7 +175,7 @@ Returns true if the queue is full
190175
isIdle: () => boolean;
191176
```
192177
193-
Returns true if all items are settled
178+
Returns true if the queuer is running but has no items to process
194179
195180
#### Returns
196181
@@ -220,7 +205,7 @@ Adds a callback to be called when a task errors
220205
221206
##### cb
222207
223-
(`error`, `task`) => `void`
208+
(`error`) => `void`
224209
225210
#### Returns
226211
@@ -242,7 +227,7 @@ Adds a callback to be called when a task is settled
242227
243228
##### cb
244229
245-
() => `void`
230+
(`result`) => `void`
246231
247232
#### Returns
248233
@@ -264,29 +249,7 @@ Adds a callback to be called when a task succeeds
264249
265250
##### cb
266251
267-
(`result`, `task`) => `void`
268-
269-
#### Returns
270-
271-
`Function`
272-
273-
##### Returns
274-
275-
`void`
276-
277-
### onUpdate()
278-
279-
```ts
280-
onUpdate: (cb) => () => void;
281-
```
282-
283-
Adds a callback to be called when an item is processed
284-
285-
#### Parameters
286-
287-
##### cb
288-
289-
(`item`) => `void`
252+
(`result`) => `void`
290253
291254
#### Returns
292255
@@ -308,28 +271,19 @@ Returns an item without removing it
308271
309272
##### position?
310273
311-
`QueuePosition`
274+
`"front"` | `"back"`
312275
313276
#### Returns
314277
315278
`undefined` \| () => `Promise`\<`TValue`\>
316279
317-
#### Example
318-
319-
```ts
320-
// Look at next item to getNextItem
321-
queue.peek()
322-
// Look at last item (like stack top)
323-
queue.peek('back')
324-
```
325-
326280
### reset()
327281
328282
```ts
329283
reset: (withInitialItems?) => void;
330284
```
331285
332-
Resets the queue to its initial state
286+
Resets the queuer to its initial state
333287
334288
#### Parameters
335289
@@ -347,7 +301,7 @@ Resets the queue to its initial state
347301
size: () => number;
348302
```
349303
350-
Returns the current size of the queue
304+
Returns the current size of the queuer
351305
352306
#### Returns
353307
@@ -365,8 +319,6 @@ Starts the queuer and processes items
365319
366320
`Promise`\<`void`\>
367321
368-
A promise that resolves when the queuer is settled
369-
370322
### stop()
371323
372324
```ts

docs/framework/react/reference/functions/useasyncqueuerstate.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ title: useAsyncQueuerState
1111
function useAsyncQueuerState<TValue>(options): readonly [() => Promise<TValue>[], {
1212
addItem: (fn, position?) => Promise<TValue>;
1313
clear: () => void;
14-
getActiveItems: () => () => Promise<any>[];
15-
getAllItems: () => () => Promise<any>[];
14+
getActiveItems: () => () => Promise<TValue>[];
15+
getAllItems: () => () => Promise<TValue>[];
1616
getExecutionCount: () => number;
1717
getNextItem: (position?) => undefined | () => Promise<TValue>;
1818
getPendingItems: () => () => Promise<TValue>[];
@@ -23,7 +23,6 @@ function useAsyncQueuerState<TValue>(options): readonly [() => Promise<TValue>[]
2323
onError: (cb) => () => void;
2424
onSettled: (cb) => () => void;
2525
onSuccess: (cb) => () => void;
26-
onUpdate: (cb) => () => void;
2726
peek: (position?) => undefined | () => Promise<TValue>;
2827
reset: (withInitialItems?) => void;
2928
size: () => number;
@@ -69,8 +68,8 @@ The state will automatically update whenever items are:
6968
readonly \[() => `Promise`\<`TValue`\>[], \{
7069
`addItem`: (`fn`, `position`?) => `Promise`\<`TValue`\>;
7170
`clear`: () => `void`;
72-
`getActiveItems`: () => () => `Promise`\<`any`\>[];
73-
`getAllItems`: () => () => `Promise`\<`any`\>[];
71+
`getActiveItems`: () => () => `Promise`\<`TValue`\>[];
72+
`getAllItems`: () => () => `Promise`\<`TValue`\>[];
7473
`getExecutionCount`: () => `number`;
7574
`getNextItem`: (`position`?) => `undefined` \| () => `Promise`\<`TValue`\>;
7675
`getPendingItems`: () => () => `Promise`\<`TValue`\>[];
@@ -81,7 +80,6 @@ readonly \[() => `Promise`\<`TValue`\>[], \{
8180
`onError`: (`cb`) => () => `void`;
8281
`onSettled`: (`cb`) => () => `void`;
8382
`onSuccess`: (`cb`) => () => `void`;
84-
`onUpdate`: (`cb`) => () => `void`;
8583
`peek`: (`position`?) => `undefined` \| () => `Promise`\<`TValue`\>;
8684
`reset`: (`withInitialItems`?) => `void`;
8785
`size`: () => `number`;

0 commit comments

Comments
 (0)