Skip to content

Commit

Permalink
general subApp.inline method (#1527)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip authored Feb 10, 2020
1 parent ecc47d3 commit 963a9f4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
28 changes: 28 additions & 0 deletions packages/subapp-web/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,34 @@ export function loadSubApp(info, renderStart, options) {
}
};

subApp.inline = ({ group, props }) => {
const groupInfo = xarc.rt.groups[group];
const fail = msg => {
console.error(msg);
return `<!--
****** ${msg}
-->`;
};

if (!groupInfo) {
return fail(`subApp inline unable to find group ${group}`);
}

const found = groupInfo.queue.find(x => {
if (x.options.name === subApp.info.name && x.options.group === group && x.options.inline) {
return x.instance;
}
return undefined;
});

if (!found) {
return fail(`subApp inline unable to find instance in group ${group} \
for subapp ${subApp.info.name}`);
}

return subApp.start(found.instance, Object.assign({}, found.options, { props }), found.info);
};

// xarc.addOnLoadStart(name, options);

// getOnLoadStart(name)
Expand Down
15 changes: 0 additions & 15 deletions packages/subapp-web/src/subapp-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,6 @@
})
.then(makeInvoke("preRender"))
.then(makeInvoke("signalReady"))
.then(() => {
return xv1.asyncMap(
groupInfo.queue.filter(x => x.options.inline),
startInfo => {
const subApp = startInfo.subApp;
subApp.inline = ({ group, props }) => {
return subApp.start(
startInfo.instance,
Object.assign({}, startInfo.options, { props }),
subApp.info
);
};
}
);
})
.then(
makeInvoke(
"start",
Expand Down

0 comments on commit 963a9f4

Please sign in to comment.