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.
loadModule¶
queueService.loadModule(ensAddress);
Load an module from ens.
Parameters¶
ensAddress
-string
: Ens address to load the module from
Returns¶
any
: module instance
loadDispatcherForQueue¶
queueService.loadDispatcherForQueue(queueEntry);
Load dispatchers for the current queue
Parameters¶
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
})
getQueueEntry¶
queueService.getQueueEntry(id, fillEmpty);
Get an specifc queue entry for the given queue id.
addQueueData¶
queueService.addQueueData(id, data, idProperties);
Add new Queue entry to the queue.
Parameters¶
id
-QueueId
: Queue id where the data should be added.data
-any
: Data that should be added.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¶
id
-QueueId
: Queue id where the data should be added.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
Example¶
queueService.removeQueueEntry(queueId)
getDispatcherService¶
queueService.getDispatcherService(queueEntry);
Gets the dispatcher service for an queueEntry, that is specified within the QueueId
.
Parameters¶
queueEntry
-QueueEntry
: queue entry to load the dispatcher service fore
Returns¶
Promise
returns any
: service instance
startSync¶
queueService.startSync(queueEntry);
Starts syncing an queue entry. It’s running the dispatchers run function.
Parameters¶
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¶
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¶
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¶
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.
onQueueFinish¶
queueService.onQueueFinish(queueId, run);
Adds an “event handle” to refresh data on queue entry finish.
Parameters¶
queueId
-QueueId
: Queue ID to check for updatesrun
-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);
}
);