Skip to content

Commit

Permalink
fix: make getSlaveRuntime function asynchronous (#548)
Browse files Browse the repository at this point in the history
Co-authored-by: maojun.ym <maojun.ym@alibaba-inc.com>
  • Loading branch information
snadn and maojun.ym committed Mar 4, 2021
1 parent cc55724 commit 6cee8e6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/plugin-qiankun/src/slave/lifecycles.ts.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ function normalizeHistory(
return normalizedHistory;
}

function getSlaveRuntime() {
const config = plugin.applyPlugins({
async function getSlaveRuntime() {
const config = await plugin.applyPlugins({
key: 'qiankun',
type: ApplyPluginsType.modify,
initialValue: {},
async: true,
});
// 应用既是 master 又是 slave 的场景,运行时 slave 配置方式为 export const qiankun = { slave: {} }
const { slave } = config;
Expand All @@ -55,7 +56,7 @@ function getSlaveRuntime() {

export function genBootstrap(oldRender: typeof noop) {
return async (props: any) => {
const slaveRuntime = getSlaveRuntime();
const slaveRuntime = await getSlaveRuntime();
if (slaveRuntime.bootstrap) {
await slaveRuntime.bootstrap(props);
}
Expand All @@ -69,7 +70,7 @@ export function genMount(mountElementId: string) {
if (typeof props !== 'undefined') {
setModelState(props);
const slaveRuntime = getSlaveRuntime();
const slaveRuntime = await getSlaveRuntime();
if (slaveRuntime.mount) {
await slaveRuntime.mount(props);
}
Expand Down Expand Up @@ -125,7 +126,7 @@ export function genUpdate() {
return async (props: any) => {
setModelState(props);
const slaveRuntime = getSlaveRuntime();
const slaveRuntime = await getSlaveRuntime();
if (slaveRuntime.update) {
await slaveRuntime.update(props);
}
Expand All @@ -141,7 +142,7 @@ export function genUnmount(mountElementId: string) {
ReactDOM.unmountComponentAtNode(container);
}

const slaveRuntime = getSlaveRuntime();
const slaveRuntime = await getSlaveRuntime();
if (slaveRuntime.unmount) await slaveRuntime.unmount(props);
};
}

0 comments on commit 6cee8e6

Please sign in to comment.