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

assemble and registerModuleInstance not working as expected #38

@cludden

Description

@cludden

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions