Skip to content

Access all routes from the $navigator object #44

Open
@mreall

Description

@mreall

It would really be helpful to have access to all the routes from the $navigator object. Right now we can only access the current route.

This would be helpful, for example, if I want to define a default transition for each route in the meta object. Then when I call this.$navigator.navigate I can pass in the default transition for the route.

routes.js example:

export default {
   routes: {
      '/page1': {
         component: Page1,
         meta: {
            transition: 'fade',
         }
      },
      '/page2': {
         component: Page2,
         meta: {
            transition: 'slideBottom',
         }
      },
}

Then in a component used for routing:

  methods: {
    /***
     * Called when a user taps a navigation button.
     * @param string to Page ID from the routes.js file.
     ***/
    route(to) {
      let transition = 'fade';
      const route = this.$navigator.getRoute(to);    // getRoute is a possible new method to access the routes.
      if (route && 'transition' in route.meta) {
        transition = route.meta.transition;
      }
      this.$navigator.navigate(to, { frame: "mainContent", transition });
    },
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions