MINERVA
Platform Documentation

Events#

Plugins can interact with Minerva by subscribing to events. These events allow plugins to respond to user actions, system events, or changes in the application state.

Add Event Listener#

To listen for specific events, plugins can use the addListener method in events object returned by window.minerva.plugins.registerPlugin. This method takes two arguments: the name of the event and a callback function to handle the event. Available Events:

{
  "name": "Example Overlay",
  "creator": "appu-admin",
  "description": "Different",
  "genomeType": null,
  "genomeVersion": null,
  "idObject": 149,
  "publicOverlay": false,
  "type": "GENERIC",
  "order": 9
}
43
{
  "name": "Generic advanced format overlay",
  "creator": "appu-admin",
  "description": "Data set provided by a user",
  "genomeType": null,
  "genomeVersion": null,
  "idObject": 20,
  "publicOverlay": true,
  "type": "GENERIC",
  "order": 9
}
{
  "name": "colored overlay",
  "creator": "appu-admin",
  "description": "",
  "genomeType": null,
  "genomeVersion": null,
  "idObject": 24,
  "publicOverlay": true,
  "type": "GENERIC",
  "order": 10
}
15
{
  type: 'drugs',
  searchValues: ['PRKN'],
  results: [
    [{
      bioEntity: {
        id: 38253,
        model: 52,
        glyph: null,
        submodel: null,
        compartment: 46644,
        elementId: 'path_0_sa11305',
        x: 18412,
        y: 3088.653195488725,
        z: 2298,
        width: 80,
        height: 40,
        fontSize: 12,
        fontColor: {
          alpha: 255,
          rgb: -16777216,
        },
        fillColor: {
          alpha: 255,
          rgb: -3342388,
        },
        borderColor: {
          alpha: 255,
          rgb: -16777216,
        },
        visibilityLevel: '4',
        transparencyLevel: '0',
        notes: '',
        symbol: 'PRKN',
        fullName: 'parkin RBR E3 ubiquitin protein ligase',
        abbreviation: null,
        formula: null,
        name: 'PRKN',
        nameX: 18412,
        nameY: 3088.653195488725,
        nameWidth: 80,
        nameHeight: 40,
        nameVerticalAlign: 'MIDDLE',
        nameHorizontalAlign: 'CENTER',
        synonyms: ['AR-JP', 'PDJ', 'parkin'],
        formerSymbols: ['PARK2'],
        activity: false,
        lineWidth: 1,
        complex: 38252,
        initialAmount: null,
        charge: null,
        initialConcentration: 0,
        onlySubstanceUnits: false,
        homodimer: 1,
        hypothetical: null,
        boundaryCondition: false,
        constant: false,
        modificationResidues: [{
          id: 58046,
          idModificationResidue: 'rs2',
          name: '',
          x: 18481.67916137211,
          y: 3118.9740341163433,
          z: 2299,
          width: 15,
          height: 15,
          borderColor: {
            alpha: 255,
            rgb: -16777216,
          },
          fontSize: 10,
          state: null,
          size: 225,
          center: {
            x: 18489.17916137211,
            y: 3126.4740341163433,
          },
          elementId: 'rs2',
        }, ],
        stringType: 'Protein',
        substanceUnits: null,
        references: [{
          link: 'https://www.genenames.org/cgi-bin/gene_symbol_report?match=PRKN',
          type: 'HGNC_SYMBOL',
          resource: 'PRKN',
          id: 173229,
          annotatorClassName: 'lcsb.mapviewer.annotation.services.annotators.HgncAnnotator',
        }, ],
        compartmentName: 'Dopamine metabolism',
        complexName: 'insoluble aggregates',
      },
      perfect: true,
    }, ],
  ],
};
{
  "modelId": 52,
  "zoom": 9.033753064925367
}
{
  "modelId": 52,
  "x": 8557,
  "y": 1675
}
{
  "id": 40072,
  "modelId": 52,
  "type": "ALIAS"
}
{
  "id": 40072
}

Marker pin:

{
  "id": "b0a478ad-7e7a-47f5-8130-e96cbeaa0cfe"
}
{
  "id": 18
}

Surface marker overlay:

{
  "id": "a3a5305f-acfa-47ff-bf77-a26d017c6eb3"
}
52
51
Example of adding event listener:#
const {
  element,
  events: { addListener, removeListener, removeAllListeners },
} = minerva.plugins.registerPlugin({
  pluginName,
  pluginVersion,
  pluginUrl,
});

const callbackShowOverlay = data => {
  console.log('onShowOverlay', data);
};

addListener('onShowOverlay', callbackShowOverlay);

Remove Event Listener#

To remove event listener, plugins can use the removeListener method in events object returned by window.minerva.plugins.registerPlugin. This method takes two arguments: the name of the event and the reference to the callback function previously used to add the listener.

const {
  element,
  events: { addListener, removeListener, removeAllListeners },
} = minerva.plugins.registerPlugin({
  pluginName,
  pluginVersion,
  pluginUrl,
});

const callbackShowOverlay = data => {
  console.log('onShowOverlay', data);
};

addListener('onShowOverlay', callbackShowOverlay);

removeListener('onShowOverlay', callbackShowOverlay);

Remove All Event Listeners#

To remove all event listeners attached by a plugin, plugins can use the removeAllListeners method in events object returned by window.minerva.plugins.registerPlugin.

const {
  element,
  events: { addListener, removeListener, removeAllListeners },
} = minerva.plugins.registerPlugin({
  pluginName,
  pluginVersion,
  pluginUrl,
});

const callbackShowOverlay = data => {
  console.log('onShowOverlay', data);
};

const callbackHideOverlay = data => {
  console.log('onHideOverlay', data);
};

const callbackOpenSubamp = data => {
  console.log('onSubmapOpen', data);
};

addListener('onHideOverlay', callbackHideOverlay);

addListener('onSubmapOpen', callbackOpenSubamp);

addListener('onShowOverlay', callbackShowOverlay);

removeAllListeners();