框架
版本
Debouncer API 参考
Throttler API 参考
速率限制器 API 参考
队列 API 参考
批处理器 API 参考
批处理器示例

AsyncQueuerOptions

接��:AsyncQueuerOptions<TValue>

定义于:async-queuer.ts:5

类型参数

TValue

属性

addItemsTo?

ts
optional addItemsTo: QueuePosition;
optional addItemsTo: QueuePosition;

定义于:async-queuer.ts:10

将项目添加到队列器的默认位置

默认值

ts
'back'
'back'

concurrency?

ts
optional concurrency: number | (queuer) => number;
optional concurrency: number | (queuer) => number;

定义于:async-queuer.ts:16

要处理的最大并发任务数。 可以是数字或返回数字的函数。

默认值

ts
1
1

expirationDuration?

ts
optional expirationDuration: number;
optional expirationDuration: number;

定义于:async-queuer.ts:21

项目可以在队列中停留的最长时间(以毫秒为单位) 如果未提供,项目将永不过期


getIsExpired()?

ts
optional getIsExpired: (item, addedAt) => boolean;
optional getIsExpired: (item, addedAt) => boolean;

定义于:async-queuer.ts:26

用于确定项目是否已过期的函数 如果提供,则此函数将覆盖 expirationDuration 行为

参数

item

TValue

addedAt

number

返回

boolean


getItemsFrom?

ts
optional getItemsFrom: QueuePosition;
optional getItemsFrom: QueuePosition;

定义于:async-queuer.ts:31

处理期间从中获取项目的默认位置

默认值

ts
'front'
'front'

getPriority()?

ts
optional getPriority: (item) => number;
optional getPriority: (item) => number;

定义于:async-queuer.ts:37

用于确定队列器中项目优先级的函数 优先级较高的项目将首先处理 如果未提供,将使用附加到任务的静态优先级值

参数

item

TValue

返回

number


initialItems?

ts
optional initialItems: TValue[];
optional initialItems: TValue[];

定义于:async-queuer.ts:41

用于填充队列器的初始项目


maxSize?

ts
optional maxSize: number;
optional maxSize: number;

定义于:async-queuer.ts:45

队列器中允许的最大项目数


onError()?

ts
optional onError: (error, queuer) => void;
optional onError: (error, queuer) => void;

定义于:async-queuer.ts:51

可选的错误处理程序,用于处理任务抛出错误时的情况。 如果提供,处理程序将使用错误和队列器实例进行调用。 这可以与 throwOnError 一起使用——处理程序将在抛出任何错误之前被调用。

参数

error

unknown

queuer

AsyncQueuer<TValue>

返回

void


onExpire()?

ts
optional onExpire: (item, queuer) => void;
optional onExpire: (item, queuer) => void;

定义于:async-queuer.ts:55

每当队列器中的项目过期时触发的回调

参数

item

TValue

queuer

AsyncQueuer<TValue>

返回

void


onIsRunningChange()?

ts
optional onIsRunningChange: (queuer) => void;
optional onIsRunningChange: (queuer) => void;

定义于:async-queuer.ts:59

每当队列器的运行状态更改时触发的回调

参数

queuer

AsyncQueuer<TValue>

返回

void


onItemsChange()?

ts
optional onItemsChange: (queuer) => void;
optional onItemsChange: (queuer) => void;

定义于:async-queuer.ts:63

每当从队列器中添加或删除项目时触发的回调

参数

queuer

AsyncQueuer<TValue>

返回

void


onReject()?

ts
optional onReject: (item, queuer) => void;
optional onReject: (item, queuer) => void;

定义于:async-queuer.ts:67

每当项目被拒绝添加到队列器时触发的回调

参数

item

TValue

queuer

AsyncQueuer<TValue>

返回

void


onSettled()?

ts
optional onSettled: (queuer) => void;
optional onSettled: (queuer) => void;

定义于:async-queuer.ts:71

可选的回调,在任务完成时调用

参数

queuer

AsyncQueuer<TValue>

返回

void


onSuccess()?

ts
optional onSuccess: (result, queuer) => void;
optional onSuccess: (result, queuer) => void;

定义于:async-queuer.ts:75

可选的回调,在任务成功时调用

参数

result

TValue

queuer

AsyncQueuer<TValue>

返回

void


started?

ts
optional started: boolean;
optional started: boolean;

定义于:async-queuer.ts:79

队列器是否应立即开始处理任务。


throwOnError?

ts
optional throwOnError: boolean;
optional throwOnError: boolean;

定义于:async-queuer.ts:85

发生错误时是否抛出错误。 如果未提供 onError 处理程序,则默认为 true;如果提供了 onError 处理程序,则默认为 false。 可以显式设置以覆盖这些默认值。


wait?

ts
optional wait: number | (queuer) => number;
optional wait: number | (queuer) => number;

定义于:async-queuer.ts:91

处理项目之间的等待时间(以毫秒为单位)。 可以是数字或返回数字的函数。

默认值

ts
0
0