Policy Class
The policy followed by a TransactionInternal.
Signature
export class Policy implements GenericTransactionPolicy
Implements: GenericTransactionPolicy
Properties
Property | Type | Description |
---|---|---|
detached | Map<DetachedSequenceId, readonly NodeId[]> | Maps detached sequences of nodes to their NodeIds |
Methods
Method | Return Type | Description |
---|---|---|
createViewNodesForTree(sequence, onCreateNode, onInvalidDetachedId) | NodeId[] | undefined | Generates tree view nodes from the supplied edit nodes. Invokes onCreateNode for each new node, and halts creation early if it returns true. Invokes onInvalidDetachedId and halts early for any invalid detached IDs referenced in the edit node sequence. |
dispatchChange(state, change) | ChangeResult | Applies a given change |
tryResolveChange(state, change) | Result.Ok<ChangeInternal> | Resolves change with Result.Ok |
validateOnClose(state) | ChangeResult | Validates the transaction when it is closed |
Property Details
detached
Maps detached sequences of nodes to their NodeIds
Signature
protected readonly detached: Map<DetachedSequenceId, readonly NodeId[]>;
Type: Map<DetachedSequenceId, readonly NodeId[]>
Method Details
createViewNodesForTree
Generates tree view nodes from the supplied edit nodes. Invokes onCreateNode for each new node, and halts creation early if it returns true. Invokes onInvalidDetachedId and halts early for any invalid detached IDs referenced in the edit node sequence.
Signature
protected createViewNodesForTree(sequence: Iterable<BuildNodeInternal>, onCreateNode: (stableId: NodeId, node: TreeViewNode) => boolean, onInvalidDetachedId: (sequenceId: DetachedSequenceId) => void): NodeId[] | undefined;
Parameters
Parameter | Type | Description |
---|---|---|
sequence | Iterable<BuildNodeInternal> | |
onCreateNode | (stableId: NodeId, node: TreeViewNode) => boolean | |
onInvalidDetachedId | (sequenceId: DetachedSequenceId) => void |
Returns
all the top-level node IDs in sequence
(both from nodes and from detached sequences).
Return type: NodeId[] | undefined
dispatchChange
Applies a given change
Signature
dispatchChange(state: ValidState, change: ChangeInternal): ChangeResult;
Parameters
Parameter | Type | Description |
---|---|---|
state | ValidState | Current state |
change | ChangeInternal | Change to apply |
Returns
a ChangeResult containing either the change result or a Failure
Return type: ChangeResult
tryResolveChange
Resolves change with Result.Ok
Signature
tryResolveChange(state: ValidState, change: ChangeInternal): Result.Ok<ChangeInternal>;
Parameters
Parameter | Type | Description |
---|---|---|
state | ValidState | Unused |
change | ChangeInternal | Change to resolve |
Returns
Result.Ok which contains change
Return type: Result.Ok<ChangeInternal>
validateOnClose
Validates the transaction when it is closed
Signature
validateOnClose(state: ValidState): ChangeResult;
Parameters
Parameter | Type | Description |
---|---|---|
state | ValidState | Current state |
Returns
a ChangeResult containing either the change result or a Failure
Return type: ChangeResult