Skip to content
This repository has been archived by the owner on Sep 13, 2019. It is now read-only.

assemble and registerModuleInstance not working as expected #38

Open
cludden opened this issue Sep 24, 2016 · 0 comments
Open

assemble and registerModuleInstance not working as expected #38

cludden opened this issue Sep 24, 2016 · 0 comments

Comments

@cludden
Copy link

cludden commented Sep 24, 2016

first off, awesome project!

ok, heres my issue. In a service, I load an entire namespace (using the scatter-plugin-all plugin), iterate over the modules and register new modules in a new namespace depending on certain configuration. this part works as expected

// psuedo-code
scatter.load('config')
.then(config => {
    scatter.load('all!workers')
    .then(workers => {
        return Object.keys(workers).map(name => [name, workers[name]]
    })
    .each(pair => {
        const [name, worker] = pair
        const data = { /* ... */ }
        if (config.enabled[name]) {
            const consumer = new Consumer(name, worker, data)
            container.registerModuleInstance(`consumers/${name}`, consumer)
        }
    })
})

the issue is, when I then try to load all of the new namespace in another module, i receive an empty object, unless i load twice. my guess is this has something to do with the caching mechanism and the fact that the new namespace is registered after startup

container.load('all!consumers')
.then(console.log) // {}
.then(() => container.load('all!consumers'))
.then(console.log) // { 'consumers/a': Consumer, 'consumers/b': Consumer }

any ideas on what I'm doing wrong?

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

1 participant