Finsemble: Linking Components

Linking Components

Frequently, users will have components that might want to share or synchronize data. A typical capital markets use case would be to link several components together so that they share the same stock symbol. Changing the stock symbol in one component would cause the other components to also change their symbol. In this case, we would call the symbol a "linkage."

Components must register themselves as linkable and specify linkage types. This registration and communication between components occurs automatically over the Finsemble Router via FSBL.Clients.LinkerClient. The Linker Client handles interfacing with the router so that you can focus on passing and receiving linked information.

Links are unique to the group and data type. Linkages are saved in the component's state.

Using The Linker

Item 1 in the image below shows the Linker icon along with a group that this component has joined. Groups are demarcated by colors—this component is in the yellow group. Groups are added or removed when a user clicks on a group in the Linker window.

Item 2 shows the Linker window and a list of colors that represent different Linker groups. By default, if a component joins a group, it will receive all messages for that group.

To transmit data to other components, simply call FSBL.Clients.LinkerClient.publish whenever you want to send out an update. This will transmit the given data to all groups that the current component has joined.

    FSBL.Clients.LinkerClient.publish({
        dataType:"symbol",
        data:"AAPL"
    });
    //To send data through the linker.This will send a `symbol` object with the symbol 'AAPL` to
    //any components that is in the same group that is listening for `symbol`

To receive data from other components through the Linker Client, you'll need to subscribe to a specific data type.

    FSBL.Clients.LinkerClient.subscribe("symbol", function(err, data){// Symbol is the data type
        if(err){
            return console.error(err);
        }
        //Do something with data. Data would be AAPL in this case.
    });

Further reading

The Linker Client automatically shares data between windows based on linkage. A user can also use the Drag and Drop Client to share data. Check out Sharing Data for more information.