Skip to main content

mountNamespace

Mounts (activates) a namespace context. All blocks that self-register (using the @tripetto decorator) when this namespace is mounted will become part of the namespace.

Signature

mountNamespace(identifier: string): INamespace

Parameters

NameTypeOptionalDescription
identifierstringNoSpecifies the identifier of the namespace to activate.

Return value

Returns a reference to the namespace.

Example

import { mountNamespace, unmountNamespace, tripetto, affects, NodeBlock } from "@tripetto/builder";

mountNamespace("custom-namespace");

// Import some blocks
import "@tripetto/blocks-dropdown";
import "@tripetto/blocks-text";

// Custom block
@tripetto({
type: "node",
identifier: "example-block",
label: "Example",
icon: "data:image/svg+xml;base64,PHN2ZyAvPg=="
})
class ExampleBlock extends NodeBlock {
// Block implementation here
}

unmountNamespace();

// The blocks `@tripetto/blocks-dropdown`, `@tripetto/blocks-text`, and
// the custom block `ExampleBlock` are now part of the namespace `custom-namespace`.

// Now, you can switch to this namespace in any builder instance.
const builder = new Builder();

builder.useNamespace("custom-namespace");