Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PerNodeState<V>

Shared state between nodes, where each node can set its own value and other nodes will keep track of them.

const values = new PerNodeState(networkOrGroup, 'name-of-value', {
defaultValue: []
});

state.set([
...
]);

Type parameters

  • V

Hierarchy

  • PerNodeState

Index

Constructors

constructor

Accessors

onUpdate

  • get onUpdate(): Subscribable<this, [node: Node<any>, value: V]>

Methods

destroy

  • destroy(): void

get

  • get(node: Node<any>): undefined | V

setLocal

  • setLocal(value: V): void

updateLocal

  • updateLocal(func: (currentValue: undefined | V, version: number) => V): void
  • Update the current value.

    Parameters

    • func: (currentValue: undefined | V, version: number) => V
      • function that will receive the current value and version and should generate the new value
        • (currentValue: undefined | V, version: number): V
        • Parameters

          • currentValue: undefined | V
          • version: number

          Returns V

    Returns void

Generated using TypeDoc