Skip to main content

CMicroAppHost<AppObjects, AppEvents>

Micro-frontend host application class (singleton). Manages hosting and coordination of multiple micro-frontend guest applications. Provides shared services like navigation, theming, analytics, and state management.

Deprecated

Use CMicroApp instead. CMicroApp now supports both guest and host use cases via selfInitialize: true and initialize().

Example

const host = new CMicroAppHost({
version: '1.0.0',
history: browserHistory,
onInit: ({ history, theme }) => {
console.log('Host initialized');
},
scriptingObjects: {
customService: new CustomService()
}
});

Type Parameters

AppObjects

AppObjects extends ScriptingObjects = Partial<ScriptingObjectTypes>

Type of custom scripting objects

AppEvents

AppEvents extends EventListeners = Events

Type of custom event listeners

Implements

  • IMicroAppHost<AppObjects, AppEvents>

Methods

addScriptingObject()

addScriptingObject<SO>(so: SO, params?: AddScriptingObjectParams): void;

Register a scripting object for child micro-apps to use. Adds the object to both the App Bridge and the SSF Host so guests using either transport can discover it. Always prefer this method over calling appBridge.addScriptingObject() directly.

Type Parameters

SO

SO extends IScriptingObject

Parameters

so

SO

The scripting object to be added.

params?

AddScriptingObjectParams

Optional parameters (e.g. { guestId } to scope to a specific guest).

Returns

void

Implementation of

IMicroAppHost.addScriptingObject

closeWaitMessage()

closeWaitMessage(): void;

Returns

void

Implementation of

IMicroAppHost.closeWaitMessage

dispatchEvent()

dispatchEvent<EventId, Params, Options>(params: DispatchEventParam<EventId, Params, Options>): Promise<void | unknown[]>;

dispatch event to child microapp

Type Parameters

EventId

EventId extends string

Params

Params extends any

Options

Options extends EventOptions

Parameters

params

DispatchEventParam<EventId, Params, Options>

event parameters

Returns

Promise<void | unknown[]>

A promise that resolves with the combined results of dispatched events.

Implementation of

IMicroAppHost.dispatchEvent

getAuthToken()

getAuthToken(): string;

Returns

string

Implementation of

IMicroAppHost.getAuthToken

getBreakpoint()

getBreakpoint(): keyof BreakPoints;

Returns

keyof BreakPoints

Implementation of

IMicroAppHost.getBreakpoint

getGuest()

getGuest<T>(id: string): T | null;

Type Parameters

T

T

Parameters

id

string

Returns

T | null

Implementation of

IMicroAppHost.getGuest

getGuests()

getGuests(): Record<string, unknown>;

Returns

Record<string, unknown>

Implementation of

IMicroAppHost.getGuests

getItem()

getItem(key: string): string | null;

Parameters

key

string

Returns

string | null

Implementation of

IMicroAppHost.getItem

getLogger()

getLogger(): MicroFrontEndLogger;

Returns

MicroFrontEndLogger


getObject()

getObject<T>(name: string): Promise<T>;

Type Parameters

T

T

Parameters

name

string

Returns

Promise<T>

Implementation of

IMicroAppHost.getObject

getProps()

getProps(): HostOptions;

Returns

HostOptions


getViewportSize()

getViewportSize(): {
height: number;
width: number;
};

Returns

{
height: number;
width: number;
}
height
height: number;
width
width: number;

Implementation of

IMicroAppHost.getViewportSize

initialize()

initialize(): Promise<HostOptions>;

Host-initiated lifecycle: loads app config, initializes the app bridge, and calls the onInit callback. Call this instead of relying on the automatic constructor chain when selfInitialize: true.

Returns

Promise<HostOptions>

host options (systemVersion, history, theme)


logout()

logout(): void;

Returns

void

Implementation of

IMicroAppHost.logout

navigate(url: To, state?: any): void;

Parameters

url

To

state?

any

Returns

void

Implementation of

IMicroAppHost.navigate

onBreakpointChangeEvent()

onBreakpointChangeEvent(eventHandler: BreakpointChangeEventHandler): string;

Parameters

eventHandler

BreakpointChangeEventHandler

Returns

string

Implementation of

IMicroAppHost.onBreakpointChangeEvent

onResizeEvent()

onResizeEvent(eventHandler: ResizeEventHandler): string;

Parameters

eventHandler

ResizeEventHandler

Returns

string

Implementation of

IMicroAppHost.onResizeEvent

openErrorBanner()

openErrorBanner(message: string): void;

Parameters

message

string

Returns

void

Implementation of

IMicroAppHost.openErrorBanner

openWaitMessage()

openWaitMessage(): void;

Returns

void

Implementation of

IMicroAppHost.openWaitMessage

publish()

publish<Type>(message: string | symbol, data?: Type): boolean;

Type Parameters

Type

Type

Parameters

message

string | symbol

data?

Type

Returns

boolean

Implementation of

IMicroAppHost.publish

removeScriptingObject()

removeScriptingObject(objectId: Extract<keyof AppObjects, string>): void;

removes scripting object from child microapp use

Parameters

objectId

Extract<keyof AppObjects, string>

unique id of the scripting object

Returns

void

Implementation of

IMicroAppHost.removeScriptingObject

renewAuthToken()

renewAuthToken(): string;

Returns

string

Implementation of

IMicroAppHost.renewAuthToken

renewSessionTimer()

renewSessionTimer(): Promise<void>;

Returns

Promise<void>

Implementation of

IMicroAppHost.renewSessionTimer

sendBAEvent()

sendBAEvent(data: BAEvent): void;

Parameters

data

BAEvent

Returns

void

Implementation of

IMicroAppHost.sendBAEvent

setItem()

setItem(key: string, value: string): void;

Parameters

key

string

value

string

Returns

void

Implementation of

IMicroAppHost.setItem

setSystemVersion()

setSystemVersion(version?: string): void;

Parameters

version?

string = 'latest'

Returns

void


subscribe()

subscribe<T>(message: string | symbol, func: SubscriptionListener<T>): string;

Type Parameters

T

T

Parameters

message

string | symbol

func

SubscriptionListener<T>

Returns

string

Implementation of

IMicroAppHost.subscribe

unsubscribe()

unsubscribe(token: string): void;

Parameters

token

string

Returns

void

Implementation of

IMicroAppHost.unsubscribe

getInstance()

static getInstance<AppObjects, AppEvents>(params?: ConstructorParams): CMicroAppHost<AppObjects, AppEvents>;

Type Parameters

AppObjects

AppObjects extends ScriptingObjects = Partial<ScriptingObjectTypes>

AppEvents

AppEvents extends EventListeners = Events

Parameters

params?

ConstructorParams

Returns

CMicroAppHost<AppObjects, AppEvents>


isInitialized()

static isInitialized(): boolean;

Returns

boolean

Properties

activeGuests

activeGuests: Record<string, unknown>;

scriptingObjects

scriptingObjects: Record<string, any>;