The Loader offers two different ways for instantiating components:

  1. Instantiate by URL
  2. Instantiate by triple stream

Instantiate by URL

The easiest way to instantiate a component is by invoking a component configuration by URL or path.

This can be done by calling: await loader.instantiateFromUrl('', ''). This returns a promise that resolves to the newly constructed instance.

This will for example instantiate the configuration at containing:

  "@id": "",
  "@type": "ex:MyModule/MyComponent",
  "ex:MyModule/MyComponent#name": "John"

This requires the component to be registered via its module.

This method takes the URI of the configuration to instantiate as first parameter, and the URL or path at which it is defined as second parameter. Note that the referenced components must be registered before, otherwise the promise will reject with an error.

Instantiate by triple stream

Similar to registration by triple stream, components can also be instantiated by triple stream.

This can be done by calling: await loader.getConfigConstructorFromStream('', myTripleStream).

Example Source