installDashletGlobal()
The library entry point. Call it first, at the top level of the dashlet script, before anything that could be deferred.
1. Signature
import { installDashletGlobal } from 'ecmind-blue-dashlet';
const dashlet = installDashletGlobal(options); // options is optional
// dashlet: Dashlet — the instance handle (page: Dashlet)
|
Call |
2. What it does
Synchronously, before returning:
-
installs
window.osDashletInit— a stable per-window dispatcher; the install is atomic and idempotent, and host calls arriving before the dashlet is configured are buffered (bounded, in arrival order) and flushed when the dashlet goes live — never dropped; -
attaches the single buffering
messagelistener (idempotent per window); -
starts the webclient wire when the origin decision allows it: a usable configured
expectedOrigingives strict mode, an omitted origin inside an iframe gives learning mode, and a top-level window without a configured origin gets no wire (see Origin configuration); -
goes live and flushes the buffered host calls and messages.
Asynchronously:
-
rich-client detection runs — an immediate throw-safe probe plus polling (Environments and detection); the state machine settles to exactly one of the three states;
-
the detection wait is bounded by
detectionTimeoutMsplus a 250 ms safety net; a timeout settles the dashlet as standalone.
3. Parameters
| Name | Type | Description |
|---|---|---|
|
|
The configuration object — see DashletOptions for
the field-by-field reference. All fields are optional; |
Behavior:
-
Idempotent registration: re-calling installs the same stable dispatcher. A later call on the same window takes over the shared sink (last configuration wins) — the previous instance’s wire simply stops receiving host events.
-
With no usable window object, or with
expectedOrigin === "*", the call throws aTypeErrorat install time (see Errors).
4. Examples
import { installDashletGlobal } from 'ecmind-blue-dashlet';
// FIRST. Top level.
const dashlet = installDashletGlobal({ expectedOrigin: 'https://enaio.example.com' });
await dashlet.init; // the normalized init context
See Quickstart for the complete minimal dashlet.