Skip to content
Daniel Alejandro Cast edited this page May 25, 2017 · 5 revisions

Plugins are meant to listen on some events triggered by the activate-power-mode package and allow to use an API which provide access to the audio, screen shake and the combo mode.

By default there are 2 plugins provided by the package: the screenShake and the audioPlay.

You can register your own consuming the activate-power-mode's service and can enable/disable it in the package's settings.

Register a plugin

To register a plugin use the service's function registerPlugin, you need to provide a code and the plugin itself.

  consumeActivatePowerModeServiceV1(service) {
    plugin = require('./my-plugin');
    service.registerPlugin('myPlugin', plugin);
  }

If you don't know how to consume the activate-power-mode's service, read the Consume the service page.

Plugin object

The plugin can be any object implementing any of the following functions depending on its needs.

// When plugin is enabled, you get the api object here.
enable(api) {}

// When plugin is disabled.
disable() {}

// When the pane is changed. If the editor is null means 
// the new active pane is not a text editor.
onChangePane(editor, editorElement) {}

// When a new cursor is added.
onNewCursor(cursor) {}

// When the user writes something. You get the cursor, 
// the screen position of the input, an input object 
// and data processed by the flow.
onInput(cursor, screenPosition, input, data) {}

// When the combo streak starts.
onComboStartStreak() {}

// When the combo level changes.
onComboLevelChange(newLvl, oldLvl) {}

// When the combo streak ends.
onComboEndStreak() {}

// When the combo shows an exclamation.
onComboExclamation(text) {}

// When the combo reach a new maximum.
onComboMaxStreak(maxStreak) {}

Additionally your plugin object can define title and description properties to be shown when the users enable/disable the plugin.

Explore the Api capabilities in the Api page.

Example

This plugin shakes the screen when new cursors are added.

'use babel'

module.exports = {
  enable(api) {
    this.api = api;
  },
  onNewCursor(cursor) {
    this.api.shakeScreen();
  }
}
Clone this wiki locally