Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

How to share the "consumed" services #67

Open
HiraveBapu opened this issue Apr 4, 2018 · 1 comment
Open

How to share the "consumed" services #67

HiraveBapu opened this issue Apr 4, 2018 · 1 comment

Comments

@HiraveBapu
Copy link

Lets say i have plugin called "data-distribution" which consumes three services service1, service2,service3. In the "data-distribution" folder / plugin, there are other js files/modules are created. In one of the module of "data-distribution" needs to access "service1", how would it access it ?

so in other words, every single file has to be "plugin" (its own folder with package.json) or can it be some higher level plugin and all other can share the imported services ?

@greuze
Copy link

greuze commented Feb 5, 2019

From your data-distribution plugin, you can access the services through imports parameter, and you can store them in a variable in that file (or other), or pass to other classes when requireing them, for example:

module.exports = function setup(options, imports, register) {
    var otherFile = require('./other-file-not-plugin')(imports.service1);

or using something like otherFile.setService(service1), that doesn't need to be a plugin.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants