Queue Utilities

Source queue-utilities

QueueId

new QueueId(ensAddress, dispatcher, id, forceReload);

Generates an queue ID by concadinating an ensAddress and a dispatcher name

Parameters

  1. ensAddress - string: ens address were the dispatcher lives;
  2. dispatcher - string: name of the exported function on the ens expose object;
  3. id - string: specification to start the same queue in seperated instances;
  4. forceReload - boolean: use force reload to disable alert when current opened ens address is the same as the currently finished dispatcher;

Example

Reference Implementation: EvanBookmarkService

this.queueId = new QueueId(
  this.description.getEvanENSAddress('addressbook'),
  'ContactsDispatcher',
  'contacts'
);

QueueSequence

new QueueSequence(name, description, run);

Used to handle one step of an dispatcher

Parameters

  1. name - string: Display name for queue (used for QueueDApp)
  2. description - string: Description for the queue (used for QueueDApp)
  3. run - Function: the function that is called to run the queue (gets the within the QueueDispatcher configured service and the data that should be handled (Array<any>: one entry for each new added QueueEntry))

Returns

Promise returns void: resolved when done

Example

new QueueSequence(
  '_dappdapps.dispatcher.save-bookmarks',
  '_dappdapps.dispatcher.save-bookmarks-description',
  async (service: BookmarkDispatcherService, data: any) => {
    await service.bookmarkService.syncQueueBookmarks();
  }
)

QueueDispatcher

new QueueDispatcher(sequence, i18n, serviceName);

Represents one dispatcher using several queueSequences, that will processed one after another, using step caches

Parameters

  1. sequence - Array<QueueSequence>: All sequences that should be runned after another
  2. i18n - any: i18n definitions for the queue
  3. serviceName - string: name of the servide that should be applied to the sequence entry

Example

export const BookmarkDispatcher = new QueueDispatcher(
  [
    sequences...
  ],
  translations
);