Hi @Crafty If I understand it correctly, the simplest solution would be to have global variable and match it with the request.
const requestPromises = new Map();
// preNavHook
async (context) => {
requestPromises.set(context.request.id, [ /* ... Promises ... */ ]);
}
...
requestHandler: async (context) => {
// my routeHandler code
await Promise.all(requestPromises.get(context.request.id));
requestPromises.delete(context.request.id);
}
...
Sometimes I see people passing their own variables to the
context
which is then passed to the
routeHandler
// preNavHook
async (context) => {
context.myPromises = [ ... ];
}
...
requestHandler: async (context) => {
// my routeHandler code
await Promise.all(context.myPromises);
}
...