queueProcessor

queueProcessor takes an observable array, observes it and calls processor once for each item added to the observable array, optionally debouncing the action.

Parameters

  • observableArray (Array<T>): observable array instance to track
  • processor
  • debounce (number): debounce time in ms. With debounce 0, the processor will run synchronously (optional. default: 0)

Returns

  • IDisposer: stops the processor

Examples

const pendingNotifications = observable([])
const stop = queueProcessor(pendingNotifications, msg => {
  // show Desktop notification
  new Notification(msg);
})

// usage:
pendingNotifications.push("test!")

results matching ""

    No results matching ""