Component types and window names
In Finsemble, every component has a componentType, while instances of a component have a windowName. These values aren't 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.
The launcher Clinet automatically generates a unique windowName for each instance of a component, unless a
name parameter is specified by configuration.
For example, let's look at ../public/configs/application/appd.json in the Finsemble seed project the component config
{
"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 later in this topic 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 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.
- 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
...
}
);
- Retrieve the
windowIdentifierinside the component itself:
let myWindowIdentifier = FSBL.Clients.WindowClient.getWindowIdentifier();
let myWindowName = myWindowIdentifier.windowName;
- Retrieve all active
windowIdentifiersand look for thewindowNamein the response:
FSBL.Clients.LauncherClient.getActiveDescriptors(
function(err,descriptors){
console.log(descriptors)
}
);
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");.
More info
You can set a component's name using configuration; see the Config Reference for details.