EvanQueue

Source queue

The evan queue synchronisation implementation. You can add entries using QueueIDs and data properties. The configured dispatchers and its Angular modules are loaded during runtime, so each dispatcher can handle angular services, also, when the DApp is not openend.

  • queue - QueueId: dapp-wrapper queue reference object to handle alsome global queue;
  • loading - boolean: is the queue loading?;
  • exception - boolean: has the queue some exceptions?;
  • allSyncing - boolean: are all queue entries syncing?;

queueCount

queueService.queueCount();

Returns the count of entries within the queue.

Returns

number: dappBrowser.queue.entries.length

Example

queueService.queueCount();

isInstantSave

queueService.isInstantSave();

Check if the queue entries should enqueued instant or only over the queue component. (currently always enabled)

Returns

boolean: True if instant save, False otherwise.

Example

queueService.isInstantSave();

loadModule

queueService.loadModule(ensAddress);

Load an module from ens.

Parameters

  1. ensAddress - string: Ens address to load the module from

Returns

any: module instance

Example

queueService.loadModule('taskboard.evan')

loadDispatcherForQueue

queueService.loadDispatcherForQueue(queueEntry);

Load dispatchers for the current queue

Parameters

  1. queueEntry - object: queue entry to load the dispatcher for

Returns

Promise returns void: applies the dispatcher instance to the queue entry

Example

this.loadDispatcherForQueue({
  queueId: {},
  data: [],
  status: 0
})

saveQueue

queueService.saveQueue(arguments);

Save the current queue to the queue db storage.

Example

queueService.saveQueue();

getQueueEntry

queueService.getQueueEntry(id, fillEmpty);

Get an specifc queue entry for the given queue id.

Parameters

  1. id - QueueId: QueueId to get
  2. fillEmpty - boolean: creates an empty queue entry

Returns

QueueEntry: The queue entry.

{
  queueId: {},
  data: [],
  status: 0
}

Example

queueService.getQueueEntry(taskboard.evan);

addQueueData

queueService.addQueueData(id, data, idProperties);

Add new Queue entry to the queue.

Parameters

  1. id - QueueId: Queue id where the data should be added.
  2. data - any: Data that should be added.
  3. idProperties - Array<string>: identity properties that should match, to remove / add queue updates

Example

this.queue.addQueueData(queueId, {
  id: '0x000',
  name: '0x000',
});

removeQueueData

queueService.removeQueueData(id, data);

Remove data entry from queue id.

Parameters

  1. id - QueueId: Queue id where the data should be added.
  2. data - any: Data that should be removed. (data is checked using data instance reference from addQueueData)

Example

this.queue.removeQueueData(queueId, {
  id: '0x000',
  name: '0x000',
});

removeQueueEntry

queueService.removeQueueEntry(id);

Remove queue entry with queue id

Parameters

  1. id - QueueId: Queue id where the data should be added.

Example

queueService.removeQueueEntry(queueId)

getDispatcherService

queueService.getDispatcherService(queueEntry);

Gets the dispatcher service for an queueEntry, that is specified within the QueueId.

Parameters

  1. queueEntry - QueueEntry: queue entry to load the dispatcher service fore

Returns

Promise returns any: service instance

Example

queueService.getDispatcherService(queueEntry);

startSync

queueService.startSync(queueEntry);

Starts syncing an queue entry. It’s running the dispatchers run function.

Parameters

  1. queueEntry - QueueEntry: The queue entry to start the synchronisation for.

Returns

Promise returns void: resolved when done

Example

queueService.startSync(queueEntry);

startSyncAll

queueService.startSyncAll(disableErrors);

Start synchronisation of the whole queue.

Parameters

  1. disableErrors - boolean (optional): dont run dispatchers with exceptions

Example

queueService.startSyncAll();

enableSyncAll

initializedModule.enableSyncAll(arguments);

Check if sync all can be triggered (when not all queue entries are running)

Returns

boolean: true if all can be started (when no queueEntry is working)

Example

queueService.enableSyncAll();

calculatePercentage

queueService.calculatePercentage(queueEntry);

Returns the current working percentage.

Parameters

  1. queueEntry - QueueEntry: The queue entry to start the synchronisation for.

Returns

number: The percentage of the queue dispatcher (if 2 of 5 sequences was solved, it returns 20)

Example

queueService.calculatePercentage(queueEntry);

setQueueStatus

initializedModule.setQueueStatus(disableEvent);

Check all queue stati (loading, exception, allSyncing) and send, that the queue stati have changed

Parameters

  1. disableEvent - boolean: dont trigger evan-queue-update

Example

queueService.setQueueStatus();

isLoading

queueService.isLoading();

Check if one queue entry is loading.

Returns

boolean: True if loading, False otherwise.

Example

queueService.isLoading();

isException

queueService.isException();

Check if an exception is represented within the queue.

Returns

boolean: True if exception, False otherwise.

Example

queueService.isException();

onQueueFinish

queueService.onQueueFinish(queueId, run);

Adds an “event handle” to refresh data on queue entry finish.

Parameters

  1. queueId - QueueId: Queue ID to check for updates
  2. run - Function: Function to call on first binding and when queue entry with the queue id has finished

Example

Reference Implementation: Task DApp

this.clearStateQueue = await this.queueService.onQueueFinish(
  this.taskService.getStateQueueId(this.taskId),
  async (queueFinish) => {
    if (queueFinish) {
      this.task.contractState = await this.taskService.getContractState(this.task.address);

      this.task.states = await this.taskService.loadTaskStates(this.task);
    }

    await this.onTodoQueueFinish(queueFinish);
  }
);