-
Notifications
You must be signed in to change notification settings - Fork 10
Inter Application Communication
The GCV can communicate with other applications via a simple messaging mechanism. Currently this is implemented via the Broadcast Channel API. Taking the smart endpoints and dumb pipes approach, the Broadcast Channel API is used simply as a pipe to pass messages between GCV and other applications; it could be easily replaced by a different API or used in tandem with another. The messages themselves (described below) are designed to be application agnostic and as succinct as possible. In other words, we want to communicate via minimum viable messages - messages that contain as little information as possible while being semantically rich enough to enable interesting interactions.
The Broadcast Channel API implements a simple publish-subscribe interface. Note, the API specification currently isn't implemented by all browsers, so it's advisable to use a polyfill for cross-browser support.
You can subscribe to a channel as follows:
var bc = new BroadcastChannel('GCV');
Here, the "GCV" channel is being subscribed to. By default, GCV does not subscribe to a channel (no inter-application communication). To enable inter-application communication, a channel must be specified. See Client Configuration for details.
Messages can then be sent as follows:
bc.postMessage('Hello, inter-app communication.');
Messages can be any object that is (de)serializable via the JSON object.
Messages can be received as follows:
bc.onmessage = function (ev) { console.log(ev.data); }
where ev
is a message event and ev.data
is the actual content that was sent.
The messages GCV currently implements conform to the following schema:
{
type: "select" | "deselect",
targets: {
organism?: String, // an organism identifier of the form "<genus> <species>"
chromosome?: String, // a chromosome identifier
genes?: String[], // an array of gene identifiers
family?: String, // a gene family identifier
extent?: Integer[2], // a length 2 array representing a genomic interval
block?: { // an object representing a pairwise synteny block
source: {
chromosome: String,
locus: Integer[2]
},
reference: {
chromosome: String,
locus: Integer[2]
},
orientation: "+" | "-"
}
}
}
Each message can specify one or more of the targets attributes. The catch is that each "select" event must be followed by a "deselect" event and each "deselect" event must be preceded by a "select" event. The targets attributes of the corresponding select and deselect events must be the same.
Finally, note that this API is under development and is subject to changes.