vaderjs 1.3.3-alpha-38 → 1.3.3-alpha-39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/runtime/router.js +10 -27
package/package.json
CHANGED
package/runtime/router.js
CHANGED
|
@@ -269,40 +269,23 @@ class VaderRouter{
|
|
|
269
269
|
// Allow pausing the route and run code before rendering
|
|
270
270
|
await new Promise(async (resolve) => {
|
|
271
271
|
await Component.router.use(req, res)
|
|
272
|
-
if(
|
|
273
|
-
|
|
274
|
-
|
|
272
|
+
if(req.pause){
|
|
273
|
+
let timer = setInterval(() => {
|
|
274
|
+
if(!req.pause){
|
|
275
|
+
resolve();
|
|
276
|
+
clearInterval(timer);
|
|
277
|
+
}
|
|
278
|
+
}, 1000);
|
|
279
|
+
}
|
|
275
280
|
});
|
|
276
281
|
} else if (Component.router.use && Component.isChild) {
|
|
277
282
|
console.warn('Router.use() is not supported in child components');
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// Check if the request is not paused
|
|
281
|
-
if (!req.pause) {
|
|
282
|
-
// Assuming Component.render() is an asynchronous function
|
|
283
|
+
}
|
|
283
284
|
const renderedContent = await Component.render();
|
|
284
285
|
document.querySelector('#root').innerHTML = renderedContent;
|
|
285
286
|
Component.bindMount();
|
|
286
287
|
Component.onMount();
|
|
287
|
-
|
|
288
|
-
console.log(`Request paused for ${req.path}`);
|
|
289
|
-
|
|
290
|
-
// Continue rendering after a delay if the request is paused
|
|
291
|
-
await new Promise((resolve) => {
|
|
292
|
-
let i = setInterval(() => {
|
|
293
|
-
if (!req.pause) {
|
|
294
|
-
clearInterval(i);
|
|
295
|
-
resolve();
|
|
296
|
-
}
|
|
297
|
-
}, 1000);
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
// Assuming Component.render() is an asynchronous function
|
|
301
|
-
const renderedContent = await Component.render();
|
|
302
|
-
document.querySelector('#root').innerHTML = renderedContent;
|
|
303
|
-
Component.bindMount();
|
|
304
|
-
Component.onMount();
|
|
305
|
-
}
|
|
288
|
+
|
|
306
289
|
} catch (error) {
|
|
307
290
|
console.error(error);
|
|
308
291
|
}
|