Skip to main content
Version: v1

NodeIdGenerator Interface

An object which can generate node IDs

Signature

export interface NodeIdGenerator

Methods

Method Return Type Description
generateNodeId(override) NodeId Generates a node identifier. The returned IDs may be used as the identifier of a node in the SharedTree. NodeIds are *always* unique and stable within the scope of the tree and session that generated them. They are *not* unique within a Fluid container, and *cannot* be compared across instances of a SharedTree. They are *not* stable across sessions/lifetimes of a SharedTree, and *cannot* be persisted (e.g. stored in payloads, uploaded in blobs, etc.). If stable persistence is needed, NodeIdConverter.convertToStableNodeId may be used to return a corresponding UUID that is globally unique and stable.

Method Details

generateNodeId

Generates a node identifier. The returned IDs may be used as the identifier of a node in the SharedTree. NodeIds are *always* unique and stable within the scope of the tree and session that generated them. They are *not* unique within a Fluid container, and *cannot* be compared across instances of a SharedTree. They are *not* stable across sessions/lifetimes of a SharedTree, and *cannot* be persisted (e.g. stored in payloads, uploaded in blobs, etc.). If stable persistence is needed, NodeIdConverter.convertToStableNodeId may be used to return a corresponding UUID that is globally unique and stable.

Signature

generateNodeId(override?: string): NodeId;

Parameters

Parameter Modifiers Type Description
override optional string if supplied, calls to convertToStableNodeId using the returned node ID will return the override instead of the UUID. Calls to generateNodeId with the same override always return the same ID. Performance note: passing an override string incurs a storage cost that is significantly higher that a node ID without one, and should be avoided if possible.

Returns

Return type: NodeId