Skip to content

Egg plugin to define multiple singletons in a convenient way.

License

Notifications You must be signed in to change notification settings

kaelzhang/egg-singletons

Repository files navigation

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

About

Egg plugin to define multiple singletons in a convenient way.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published