Lifecycle Events

The Finsemble Library has several events that your components and clients can listen for.

onReady

The FSBL onReady event is fired when all registered clients have completed their initialization. Any code depending on the entire library being initialized (e.g., rendering a React component) should be executed inside of the onReady callback. At this point, Finsemble is ready to be used.

if (window.FSBL && FSBL.addEventListener) {
	FSBL.addEventListener("onReady", init);
} else {
	window.addEventListener("FSBLReady", init);
}

Clients also have an onReady event. You can attach callbacks to this event in the same way that you attach a callback to the Finsemble Library.

FSBL.Clients.WindowClient.addEventListener("onReady", function() {
	// Do things with the Window Client.
});

FSBL.Clients.WindowClient.onReady(function() {
	// Do things. Equivalent to the code above.
});

authorizationCompleted

There is an optional FSBL dependency capability called authorizationCompleted. A service or component can wait on this event. Logically, start-up is in two stages. Most services are started before the app attempts to authenticate the user. These services use the dependency manager.

Those services that depend (directly or transitively) on user credentials (workspace, preferences, docking) wait on the authorizationCompleted event. As such, they won't be started until after the user authenticates (or if no authentication is required).

The odd man out is the Launcher Service which operates in two stages. Its core capabilities (launching) are available immediately, but secondary capabilities (search, system tray, CSS overrides) only come online after authentication.

onReady only triggers in components after completing stage 2.


Further reading

Learn more about how Finsemble sends and receives events by reading about the Router.

Check out the Build Process for details about middleware that interfaces with clients and components.