Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin config should support promises. #73

Closed
JoshMcCullough opened this issue Oct 7, 2016 · 0 comments
Closed

Plugin config should support promises. #73

JoshMcCullough opened this issue Oct 7, 2016 · 0 comments

Comments

@JoshMcCullough
Copy link
Contributor

Current behavior:
Plugin configuration callbacks are expected run synchronously.

Expected/desired behavior:

  • What is the expected behavior?
    The callback passed into aurelia.use.plugin to configure the plugin should allow for the return of a Promise. Configuration of Aurelia should not be considered "done" until all plugin configuration callbacks have been resolved or rejected.
  • What is the motivation / use case for changing the behavior?
    To allow for more complex/async configuration of plugins, before Aurelia is loaded.

Example

aurelia.use
    .standardConfiguration()
    .plugin('aurelia-configuration', config => {
        config.setDirectory(System.baseURL + '/config');
        config.setConfig('application.json');
        config.setEnvironment('development');

        // Returns a promise.
        return config.mergeConfigFile(`${config.directory}/application-overrides.json`);
    });

return aurelia.start().then(a => a.setRoot());

Workaround

let promises = [];

aurelia.use
    .standardConfiguration()
    .plugin('aurelia-configuration', (config) => {
        config.setDirectory(System.baseURL + '/config');
        config.setConfig('application.json');
        config.setEnvironment('development');

        promises.push(config.mergeConfigFile(`${config.directory}/application-overrides.json`));
    });

// Allow any async configuration to complete before starting Aurelia.
return Promise
    .all(promises)
    .then(() => {
        return aurelia.start().then(a => a.setRoot());
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant