on( eventName, callback )
| argument | type | optional | default | description |
|---|---|---|---|---|
| eventName | String | false | - | The name of the event to subscribe to |
| callback | Function | false | - | The listener callback function invoked when the event fires |
Subscribes to an event on the emitter instance. In modern TypeScript Strelit UI Kit, callbacks use
arrow functions or standard closure binding without requiring legacy
context parameters.
off( eventName, callback )
| argument | type | optional | default | description |
|---|---|---|---|---|
| eventName | String | false | - | The name of the event to unsubscribe from |
| callback | Function | false | - | The specific callback listener previously registered with |
Removes the specified listener from the event. unbind is maintained as a
backward-compatible alias for off.
emit( eventName, …args )
| argument | type | optional | default | description |
|---|---|---|---|---|
| eventName | String | false | - | The name of the event to emit |
| …args | any[] | true | - | Arguments passed to listeners |
Notifies listeners of an event and passes arguments along. trigger is an alias for
emit.
addEventListener( eventName, callback ) & removeEventListener( eventName, callback )
Standard Web-aligned aliases for on() and off().
emitBaseBubblingEvent( eventName )
Emits a hierarchical event that bubbles up the layout tree (from
ComponentItem through parent Stack,RowOrColumn, up to the
root layout). Receiving callbacks are passed an instance of EventEmitterBubblingEvent
:
event.name: The string name of the event.event.target: The originalEventEmitterthat initiated the bubbling event.event.stopPropagation(): Prevents further bubbling up the layout tree hierarchy.event.isPropagationStopped: Boolean indicating whether propagation was stopped.
EventHub & Multi-Window Sync
Each StrelitLayout instance manages an EventHub (accessible via
layout.eventHub) that facilitates message passing across all detached popout windows
(BrowserPopout instances) and the main window:
// Emit a custom message across all detached windows and the main layout
layout.eventHub.emitUserBroadcast('tickerUpdated', { symbol: 'AAPL', price: 185.5 });
// Listen for broadcast messages anywhere in the application
const handleBroadcast = (data) => {
console.log('Received multi-window event:', data);
};
layout.eventHub.on('userBroadcast', handleBroadcast);
// Unsubscribe when component unmounts
layout.eventHub.off('userBroadcast', handleBroadcast);