Component Types and Window Names

In Finsemble, every component has a componentType, while instances of a component have a windowName. These values are not normally exposed to the end user; they are simply how Finsemble internally addresses each component.

A componentType is a key in the finsemble.components configuration object.

A unique windowName is automatically generated by the Launcher Client for each instance of a component, unless a name parameter is specified by configuration.

For example, let's look at ../configs/application/components.json in the Finsemble seed project the component config for the Welcome component:

{
    "comment": "Sample component configuration",
    "components": {
        "Welcome Component": {
            "window": {
                "url": "$applicationRoot/components/welcome/welcome.html",
                "affinity": "workspaceComponents",
                "frame": false,
                "resizable": true,
                "autoShow": true,
                "top": "center",
                "left": "center",
                "width": 400,
                "height": 432
            },

In this instance, "Welcome Component" is the componentType. We can see that the unique windowName generated was: "Welcome Component-9-3540-Finsemble". There are several methods for discovering a window's unique windowName, see below for details.

windowIdentifier

Component instances are often referred to in Finsemble API calls via a windowIdentifier. A windowIdentifier is an object with both windowName and componentType properties.

A windowIdentifier can be constructed as:

let windowIdentifier = {
	"windowName": "<windowName>",
	"componentType": descriptors[<window name>].customData.component.type
};

Discovering a window's name

You will often need to retrieve a window's name to make a Finsemble API call referencing the window, e.g., to construct a windowIdentifier for use with LauncherClient.showWindow() or LinkerClient.linkToChannel(). There are several ways to retrieve this information.

  1. Retrieve a response from the LauncherClient.spawn() call:
FSBL.Clients.LauncherClient.spawn(
	"Welcome Component",
	{addToWorkspace: true},
	function(err, response) {
		let newWindowIdentifier = response.windowIdentifier;
		let newWindowName = newWindowIdentifier.windowName;
		//do something with the windwIdentifier or windowName
		...
	}
);
  1. Retrieve the windowIdentifier inside the component itself:
let myWindowIdentifier = FSBL.Clients.WindowClient.getWindowIdentifier();
let myWindowName = myWindowIdentifier.windowName;
  1. Retrieve all active windowIdentifiers and look for the windowName in the response:
FSBL.Clients.LauncherClient.getActiveDescriptors)
    function(err,descriptors){
         console.log(descriptors)
    }
  );

Note: The response is an object where the keys windowNames and componentTypes can be found at:

descriptors[<window name>].customData.component.type

Clarification about names

There are a few values that sound similar, but behave differently. These are all documented in the Config Reference.

displayName

The displayName is a component's in the app launcher menu and the label in the pinned item section of the toolbar. It is set in the component configuration at: component.displayName.

name

In the event that you specify a name value in the component configuration, the component instances will always be generated with the specified windowName. This limits instances of the component to one. There are more ideal mechanisms for achieving this (such as by setting the component.singleton property in the component's config).

title

The title displayed in the window title bar is a separate value which can either be set in the component's config (at foreign.components.Window Manager.title) or programmatically by using: FSBL.Clients.WindowClient.setWindowTitle("My window's title");.

Further reading

You can set a component's name using configuration; see the Config Reference for details.