@graphty/graphty-element / session / RunQueue
Interface: RunQueue ​
Defined in: graphty-element/src/session/runs/RunsApi.ts:114
The element's operation queue, as a run needs it.
OperationQueueManager satisfies this structurally: the point of writing it down rather than importing the class is that the session stays free of the renderer's manager graph, and that a test can drive a run without a queue at all.
Methods ​
cancelOperation() ​
cancelOperation(
operationId):boolean
Defined in: graphty-element/src/session/runs/RunsApi.ts:150
Stop one queued or running operation.
Parameters ​
operationId ​
string
The id queueOperation returned.
Returns ​
boolean
True when there was something to stop.
queueOperation() ​
queueOperation(
category,execute,options?):string
Defined in: graphty-element/src/session/runs/RunsApi.ts:127
Put work in the queue.
Parameters ​
category ​
"style-edit" | "algorithm-run"
Which of the queue's categories this run belongs to, and therefore which obsolescence rules apply to it. "algorithm-run" is a computation over the graph, which arriving data makes stale and so cancels; "style-edit" is a write to the style stack, which is a standing instruction about how to paint whatever the graph holds and which nothing obsoletes. The queue's remaining categories are not runs.
execute ​
(context) => void | Promise<void>
The work.
options? ​
What to call it in the queue's own events.
description? ​
string
The description the queue's events carry.
Returns ​
string
The queue's operation id, which is not the run id.
settled() ​
settled():
Promise<void>
Defined in: graphty-element/src/session/runs/RunsApi.ts:144
Resolve once nothing is queued or running.
WHAT THIS EXISTS TO ANSWER. The element starts work of its own that nobody awaited -- a run's suggested encoding lands on the run's first completion, deliberately without making a consumer await the picture in order to have started the run. So await runs.start(...) hands back the numbers while the paint is still on its way, and a consumer that read the layer stack or the legend right then saw the picture as it stood a moment ago. Working that out by counting turns is coordination code, and coordination code the element should not be shipping to a consumer.
Returns ​
Promise<void>
A promise that resolves when the queue is empty.