Skip to content

Consume the service

Daniel Alejandro Cast edited this page May 22, 2017 · 2 revisions

activate-power-mode provides a service so you can consume and register your own plugins, effects and flow. It's as easy as declare in your package's package.json the following:

{
  "consumedServices": {
     "activate-power-mode": {
       "versions": {
         "^1.0.0": "consumeActivatePowerModeServiceV1"
       }
     }
   }
}

and in your package's main file:

'use babel'

module.exports = {
  activate() {},
  consumeActivatePowerModeServiceV1(service) {
    // register what you want with the service
  },
}

Package dependency

Optionally, you can use the atom-package-deps node module to define a dependency for the activate-power-mode package and ask to install it.

deps

Install it with:

npm install atom-package-deps --save

define the dependency in your package's package.json:

{
  "package-deps": ["activate-power-mode"]
}

and in your activate ask for the requirement:

'use babel'

module.exports = {
  activate() {
    require('atom-package-deps').install('your-package-name');
  },
  consumeActivatePowerModeServiceV1(service) {
    // register what you want with the service
  },
}
Clone this wiki locally