Lifecycle Events

The Finsemble Library has several events that your components and clients can listen for. As we add events to the library, we will update this list.


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.

FSBL.addEventListener('onReady', function(){
    // Do things

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.

    // Do things. Equivalent to the code above.


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.


The onShutdown event is an optional method that your services and components can tap into. It allows you to do any cleanup actions on application shutdown. To handle any egregiously long clean-up tasks, you can set a timeout in your config. The default is ten seconds. To change this, simply set the "shutdownTimeout" property in configs/application/config.json to a number in milliseconds.

When FSBL.shutdownApplication() is invoked, it sends a message to the core application, our service manager. onShutdown is completed in three stages.

  1. Our service manager fires a message to every service that is online. This is called the shutdownRequest.
  2. When the service receives the request, it returns a shutdownResponse. This response tells the service manager whether it should wait for clean-up methods to complete before killing the application. This is all handled under the hood. If a service registers any onShutdown event handlers, a response is sent to the service manager telling it to wait.
  3. If the service has any clean-up methods, it sends off shutdownComplete when they've finished. If there are no registered onShutdown event handlers, this message is sent immediately after the shutdownResponse.

Next, we'll show you a couple of examples that tap in to onShutdown.

Example: onShutdown in a component

//LauncherService will send out a request to every component, asking them to complete any shutdown actions. This callback is invoked if the component is open when the application quits.
FSBL.addEventListener('onShutdown', function() {
    return new Promise(function(resolve, reject){

Example: onShutdown in a service

//Asynchronous callback onShutdown
    return new Promise(function(resolve, reject){

//Synchronous callback
myService.onShutdown(function cleanup1 (){
    //callback will work asynchronously even if you pass in a non-promise.

myService.onShutdown(function cleanup2 (){
    //`onShutdown` can handle more than one callback. They can be a mix of promises an non-promises
    return new Promise(function(resolve, reject){

Example flow: LauncherService

  1. App requests shutdown.
  2. Service Manager requests that all services clean up. All services begin cleaning up.
  3. Launcher Service receives message, tells the Service Manager to wait until all of the components it launched have had time to shut down. It then sends a message to every component, notifying them to complete any onShutdown event handlers.
  4. All components have responded, so Launcher Service fires off onShutdownComplete.
  5. When all services have completed shutdown, the app quits.

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.