Toolforge Docs
DocsIO PrimitivesprogressLoader

progressLoader

Creates a progress loader for tracking progress of operations with multiple items.

Usage

Progress bar

const progress = await io
  .progressLoader({
    title: 'Processing Orders',
    description: 'Processing orders in queue',
    itemsInQueue: 10,
  })
  .start()

// Process items one by one
for (let i = 0; i < orders.length; i++) {
  await processOrder(orders[i])
  await progress.increment()
}

await progress.stop()

Props

PropDescriptionTypeRequiredDefault
titleTitle of the progress operationstringYes
descriptionOptional description of the progress operationstringNoundefined
itemsInQueueThe total number of items in the queuenumberYes

Returns

Returns a ProgressLoader instance with start(), increment(), update(itemsCompleted), and stop() methods.

Examples

Progress tracking

const progress = await io
  .progressLoader({
    title: 'Processing Orders',
    itemsInQueue: orders.length,
  })
  .start()

try {
  for (const order of orders) {
    await processOrder(order)
    await progress.increment()
  }
} finally {
  await progress.stop()
}

On this page