Closed xziy closed 1 month ago
The current decorator function, queued(), aims to provide a queuing mechanism for asynchronous operations. However, it could be improved to offer enhanced functionality and broader applicability.
queued()
interface QueueItem { queue: Promise<void>; } function queued() { return function (_target: any, _key: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise<any>>) { const operationQueue: QueueItem = { queue: Promise.resolve() }; const method = descriptor.value!; descriptor.value = async function (...args: any[]) { const operation = operationQueue.queue.then(async () => { return await method.apply(this, args); }); operationQueue.queue = operation.catch(() => {}); return operation; }; return descriptor; }; }
Your contributions and insights to enhance this decorator are highly appreciated. Thank you for considering this request.
i found it here: https://gist.github.com/RomkeVdMeulen/f774324202d3fb8b710e7e2b1dcfdeb0#file-operationqueue-ts
Hi, can't you achive the same withthe ThrottleAsync decorator: https://vlio20.github.io/utils-decorators/#throttleAsync
Feature Request:
Overview:
The current decorator function,
queued()
, aims to provide a queuing mechanism for asynchronous operations. However, it could be improved to offer enhanced functionality and broader applicability.Code Sample:
Additional Information:
queued()
decorator will be crucial for seamless adoption.Possible Implementation:
Your contributions and insights to enhance this decorator are highly appreciated. Thank you for considering this request.
i found it here: https://gist.github.com/RomkeVdMeulen/f774324202d3fb8b710e7e2b1dcfdeb0#file-operationqueue-ts