These are chat archives for canjs/canjs

8th
Mar 2018
Jeroen Cornelissen
@jeroencornelissen
Mar 08 2018 13:25

@justinbmeyer Yes, 4.0. My setup is simular to bitballs, with a stache helper that renders a can-import dynamically.
In main.js:

route.data = routing;
route.register('{page}/{subpage}');
route.register('{page}/{subpage}/{itemId}');
route.start();

routing.js:

const Routing = DefineMap.extend('Routing', {
  page: { type: 'string', default: 'tickets' },
  subpage: { type: 'string', default: 'list' },
  itemId: { type: 'string' },
  get pageConfig() {
    if (pageConfigs[this.page] === undefined) {
      this.update({ subpage: 'list', page: 'tickets' }); // default route
      return pageConfigs[this.page];
    } else if (this.page.toLowerCase() === 'tickets') {
      return pageConfigs[this.page];
    } else { // admin
      let pageConfig = pageConfigs[this.page][this.subpage];
      if (pageConfig === undefined) {
        this.subpage = 'settings’; // default admin route
        return pageConfigs[this.page][this.subpage];
      }
      return pageConfig;
    }
  }
});

With possible routes to:
#!/admin/settings
#!/admin/priviliges
#!/tickets/list
#!/tickets/list/{Filter.id}
#!/tickets/detail/{Ticket.id}
...

Justin Meyer
@justinbmeyer
Mar 08 2018 18:05
Cool stuff from Chris ... https://forums.donejs.com/t/improving-initial-render-performance-with-can-defer/817 <-- delays expensive component rendering!
oh, you probably don't want to be calling .update() and instead want to use the defaults in .register("...", defaults)
@jeroencornelissen
Jeroen Cornelissen
@jeroencornelissen
Mar 08 2018 19:35
Thx, @justinbmeyer. You’re right .update() wasn’t a good idea :clap:
Jeroen Cornelissen
@jeroencornelissen
Mar 08 2018 19:41
@justinbmeyer Hmm, I removed the routeUrl helper in my stache also and did the route directly <a href="#!/admin/settings”> and that solved the issue.
When I do: {{routeUrl(page='admin' subpage='settings')}} the route flickers from #!&page=admin&subpage=settings to #!&page=admin&subpage=settings.