Skip to content

initializeModelAdapter

since v1.1.0

initializeModelAdapter(adapter, model?, injector?, options?): ModelAdapter

Initializes an existing model adapter for use in ng-diagram.

Prepares all nodes and edges in the adapter so they are ready for rendering by ng-diagram. Use this when providing a custom ModelAdapter implementation.

ModelAdapter

An existing ModelAdapter to initialize.

Partial<Model>

Optional initial model data to seed the adapter with.

Injector

Optional Angular Injector if not running inside an injection context.

InitializeModelOptions

Optional InitializeModelOptions. ⚠️ Overriding the strip functions can and probably will break the diagram — use at your own risk. Note that for custom adapters these functions only affect initialization; keeping serialization consistent in your adapter’s toJSON() is up to you.

ModelAdapter

// Basic usage with a custom adapter
model = initializeModelAdapter(new NgRxModelAdapter(this.store));
// With initial model data to seed the adapter
model = initializeModelAdapter(new NgRxModelAdapter(this.store), {
nodes: [{ id: '1', position: { x: 0, y: 0 }, data: { label: 'Node 1' } }],
edges: [],
});
// With an explicit injector (outside injection context)
model = initializeModelAdapter(new NgRxModelAdapter(this.store), undefined, this.injector);
VersionChanges
v1.1.0Introduced
v1.3.0Added options parameter for customizing runtime-property stripping