1.0.1 • Published 6 years ago

egg-singletons v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

Build Status Coverage

egg-singletons

Egg plugin to define multiple singletons in a convenient way.

Install

$ npm install egg-singletons

Configurations

config/plugin.js

exports.singletons = {
  enable: true,
  package: 'egg-singletons'
}

config/config.default.js

exports.singletons = {
  foo: {
    // Load into app, default is open
    app: true,
    // Load into agent, default is close
    agent: false,
    create: (config, app) => {
      return a => {
        console.log(a)
      }
    }
  }
}

Then:

...
  async doSomething () {
    this.app.foo('hello')
  }
...

License

MIT