question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Research the router export

See original GitHub issue

Right now we lazy import and initialize the router here:

https://github.com/IBM/pwa-lit-template/blob/5fb2c633276bf0b4bdcc339d9a3c7f1f988a0359/src/components/app-index.ts#L81-L89

This router.init() function doesn’t export anything:

https://github.com/IBM/pwa-lit-template/blob/5fb2c633276bf0b4bdcc339d9a3c7f1f988a0359/src/router/index.ts#L13-L27

Doing it this way, we found a problem: We can’t import the router instance to use the router helpers.

For example, we want to replace the hardcoded link in the not found page to use the router name. From this:

https://github.com/IBM/pwa-lit-template/blob/5fb2c633276bf0b4bdcc339d9a3c7f1f988a0359/src/pages/page-not-found.ts#L29

To something like this:

<a href="${router.urlForName('home')}">Back to home</a> 

And the same for the navigation links:

https://github.com/IBM/pwa-lit-template/blob/5fb2c633276bf0b4bdcc339d9a3c7f1f988a0359/src/components/app-index.ts#L57-L61

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
web-padawancommented, Jul 20, 2020

I will experiment with your branch later today, and will try to come up with a better approach.

2reactions
web-padawancommented, Jun 17, 2020

I would consider using async directive for urlForName helpers.

let routerInstance;

export const initRouter = async (outlet) => {
  if (!routerInstance && outlet) {
    const router = await import('../router/index');
    routerInstance = router.init(outlet);
  }
  return routerInstance;
};

export const waitForRouter = () => {
  return new Promise((resolve) => {
    if (routerInstance) {
      resolve(routerInstance);
    } else {
      setTimeout(() => waitForRouter(), 100);
    }
  });
};

// use "until" directive to use helpers asynchronously
export const urlForName = (name) => {
  return until(waitForRouter().then((r) => r.urlForName(name)), '');
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js Express export routes for organization? - Stack Overflow
In your new routes module (eg in api/myroutes.js ), export the module. var express = require('express'); var router = express.
Read more >
The Research and Application of Multiple-Export Strategy ...
This paper shows how to use an open virtualisation architecture to analyse and improve the forwarding performance of a virtual router. In ...
Read more >
Routing and storage overview | Cloud Logging
You can route log entries to destinations like Logging buckets, which store the log entry, or to Pub/Sub. To export your logs into...
Read more >
Router Exports from Singapore - Volza.com
8517.70 ROUTER N/A Sri Lanka 23600 00000000 ETHERNET SECURITY ROUTER & PARTS N/A Sri Lanka 127 8207.50 ROUTER BITS N/A Sri Lanka 58 8517.70 ROUTER N/A...
Read more >
User Security Configuration Guide, Cisco IOS Release 15MT
The IP Traffic Export feature allows users to configure their router to export IP packets that are received on multiple, simultaneous WAN or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found