Create a new TaskManager
SNApiClient instance for making API requests
The ID of the task to monitor
Optional configuration for polling behavior
Wait for the task to complete by polling its status
This method periodically checks the task status until it reaches a terminal state (completed or failed). It will continue polling at the configured interval until either:
Promise resolving to the completed task details
const taskManager = new TaskManager(client, 'task-123', {
pollInterval: 1000, // Poll every second
timeout: 60000 // 1 minute timeout
});
try {
const task = await taskManager.waitForCompletion();
console.log('Task completed successfully');
} catch (error) {
console.error('Task did not complete:', error.message);
}
Wait for download task completion using Server-Sent Events (SSE)
This method provides real-time monitoring of download task status via SSE,
which is more efficient than polling. It listens for the sdk:completed event
to detect task completion, and handles error events appropriately.
Promise resolving when the task completes successfully
TaskManager monitors the status of a Cascade task using a polling strategy.
This class provides a polling-based mechanism to track task completion, serving as a fallback to the preferred SSE (Server-Sent Events) method. It periodically queries the task status endpoint until the task reaches a terminal state (completed or failed).
Example