Skip to content

initializeModelAdapter

since v1.1.0

initializeModelAdapter(adapter, model?, injector?): 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.

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);