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

Allow appOptions to resolve asynchronously #69

Merged
merged 1 commit into from
Feb 3, 2021

Conversation

Sergej-Popov
Copy link
Contributor

@Sergej-Popov Sergej-Popov commented Feb 3, 2021

What: This PR adds the ability to resolve app options asynchronously.
Why: In some scenarios (e.g. multi-tenant applications) resolution of app options such as a router, i18n etc, requires loading configuration and resources asynchronously.

At the moment there are no asynchronous hooks except loadRootComponent which is insufficient.

Example:

const vueLifecycles = singleSpaVue({
  Vue,
  async appOptions () {
    const config = await loadConfiguration()

    const i18n = await  i18nFactory(config);
    const router = await  routerFactory(config);

    return {
      render: h => h(App),
      router,
      i18n
    }
  }
});

export const bootstrap = vueLifecycles.bootstrap;
export const mount = vueLifecycles.mount;
export const unmount = vueLifecycles.unmount;

Copy link
Member

@joeldenning joeldenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the change, thanks for adding tests for the code and types.

Could you help with updating the documentation for single-spa-vue? Here's the file to modify:

https://github.com/single-spa/single-spa.js.org/blob/master/website/versioned_docs/version-5.x/ecosystem-vue.md

I'll merge and publish this now

@joeldenning
Copy link
Member

I've created single-spa/single-spa.js.org#403 to track documenting this feature.

@joeldenning
Copy link
Member

This is released in https://github.com/single-spa/single-spa-vue/releases/tag/v2.2.0

@Sergej-Popov
Copy link
Contributor Author

Thanks for releasing so quickly. Docs: single-spa/single-spa.js.org#405

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

Successfully merging this pull request may close these issues.

None yet

2 participants