Skip to content

Commit

Permalink
dep: xaa 1.6.0 (#1669)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip authored Jun 9, 2020
1 parent 5a59e2b commit 512cdb5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
37 changes: 10 additions & 27 deletions packages/subapp-web/lib/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const DEFAULT_CONCURRENCY = 15;
const xaa = require("xaa");

/*
* subapp start for SSR
* Nothing needs to be done to start subapp for SSR
Expand All @@ -24,26 +25,20 @@ module.exports = function setup() {
/*
*/
const waitForPrepare = async (info, mapCtx) => {
if (mapCtx.failed) {
return;
}
mapCtx.assertNoFailure();

// make sure subapp is ready with SSR
if (info.ready) {
await info.ready.promise;
}

if (mapCtx.failed) {
return;
}
mapCtx.assertNoFailure();

// and then wait for it to complete data prepare
// awaitData should be available once ready is awaited
await info.awaitData;

if (mapCtx.failed) {
return;
}
mapCtx.assertNoFailure();

if (info.saveSSRInfo) {
info.saveSSRInfo();
Expand All @@ -53,17 +48,13 @@ module.exports = function setup() {
/*
*/
const runSSR = async ({ lib, renderSSR }, mapCtx) => {
if (mapCtx.failed) {
return;
}
mapCtx.assertNoFailure();

if (lib && lib.realizeReduxStore) {
await lib.realizeReduxStore();
}

if (mapCtx.failed) {
return;
}
mapCtx.assertNoFailure();

if (renderSSR) {
await renderSSR();
Expand Down Expand Up @@ -92,34 +83,26 @@ module.exports = function setup() {
Object.entries(xarcSubappSSR),
async ([group, { queue }], ix, mapCtx) => {
if (group !== "_") {
if (mapCtx.failed) {
return;
}
mapCtx.assertNoFailure();

// first ensure everyone in the queue finish preparing
await xaa.map(
queue,
async (v, ix2, ctx2) => {
if (mapCtx.failed) {
return;
}
ctx2.assertNoFailure();

await waitForPrepare(v, ctx2);
},
{ concurrency }
);

if (mapCtx.failed) {
return;
}
mapCtx.assertNoFailure();

// and then kick off rendering for every subapp in the group
await xaa.map(
queue,
async (v, ix2, ctx2) => {
if (mapCtx.failed) {
return;
}
ctx2.assertNoFailure();

await runSSR(v, ctx2);
},
Expand Down
2 changes: 1 addition & 1 deletion packages/subapp-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"optional-require": "^1.0.0",
"request": "^2.88.0",
"subapp-util": "^1.0.5",
"xaa": "^1.4.0"
"xaa": "^1.6.0"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
Expand Down

0 comments on commit 512cdb5

Please sign in to comment.