-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
use-queue.types.ts
51 lines (48 loc) · 1.25 KB
/
use-queue.types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { ProgressType, RequestInstance, QueueElementType } from "@hyper-fetch/core";
export type UseQueueOptionsType = {
queueType?: "auto" | "fetch" | "submit";
};
export type QueueRequest<Request extends RequestInstance> = QueueElementType<Request> & {
/**
* Uploading progress for given request
*/
uploading?: ProgressType;
/**
* Downloading progress for given request
*/
downloading?: ProgressType;
/**
* Callback which allow to start previously stopped request.
*/
startRequest: () => void;
/**
* Callback which allow to stop request and cancel it if it's ongoing.
*/
stopRequest: () => void;
/**
* Removes request from the queue
*/
deleteRequest: () => void;
};
export type UseQueueReturnType<T extends RequestInstance> = {
/**
* Queue status for provided request
*/
stopped: boolean;
/**
* List of requests for provided request
*/
requests: QueueRequest<T>[];
/**
* Callback which allow to stop queue, it will cancel ongoing requests.
*/
stop: () => void;
/**
* Callback which allow to pause queue. It will allow ongoing requests to be finished, but will stop next from being send.
*/
pause: () => void;
/**
* Callback which allow to start queue.
*/
start: () => void;
};