Initializes a new instance of that class.
Optional options: Nilable<IQueueOptions<IQueueStorage>>Custom options.
Private Readonly _errorPrivate _isPrivate Readonly _tasksPrivate Readonly getGets if queue is running or not.
A value, which indicates if queue is running or not.
Gets the underlying storage.
The storage.
Queues a task.
const queue = new Queue();
/// ... register 'myTask1'
// enqueue (and execute) without data
await queue.enqueue('myTask1');
// with data
await queue.enqueue('myTask1', {
data: { foo: 'bar' }
});
The promise with the context.
The key / ID of the task.
Optional options: Nilable<IQueueEnqueueOptions>Additional and custom options.
Private getPrivate initRegisters one or more error handlers.
This instance.
The name of the known event.
The handler to register.
Registers one or more task actions, seperated by keys.
const queue = new Queue();
queue.register({
'myTask1': async (context) => {
// your code ...
}
});
// from here, you should be able to
// enqueue tasks with key/ID 'myTask1'
Rest ...tasks: QueueTaskToRegister[]Generated using TypeDoc
A queue / task manager.
Example