diff --git a/packages/subapp-web/src/index.js b/packages/subapp-web/src/index.js index a3ef1635b..82c820d02 100644 --- a/packages/subapp-web/src/index.js +++ b/packages/subapp-web/src/index.js @@ -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 ``; + }; + + 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) diff --git a/packages/subapp-web/src/subapp-web.js b/packages/subapp-web/src/subapp-web.js index bccdc7b24..3b18448a2 100644 --- a/packages/subapp-web/src/subapp-web.js +++ b/packages/subapp-web/src/subapp-web.js @@ -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",