usePromisesQueue
3p-core / usePromisesQueue
Function: usePromisesQueue()
usePromisesQueue(
onStart?
,onFinish?
):IUsePromisesQueueResult
React hook to create a persistent PromiseQueue
instance tied to the component lifecycle.
Ideal for queueing async actions like SharePoint list operations, file uploads, etc.
Parameters
onStart?
() => void
Optional callback triggered when queue processing begins.
onFinish?
() => void
Optional callback triggered when queue processing ends.
Returns
An object with the addToQueue
method to enqueue operations.
Example
const { addToQueue } = usePromisesQueue();
const handleClick = () => {
addToQueue(() => sp.web.lists.getByTitle("MyList").items.add({ Title: "New" }));
};