Skip to content

Router - passing an object with route params into handler #3799

@ntgn81

Description

@ntgn81

Currently, matched parameters are passed into the action as an array

routes: {
  "folder/:name-:mode": "openFolder"
},

openFolder: function(name, mode, queryString) {
  // do stuff
}

I would like the actions to be given an object with name, params, queryString instead, resembling express routing solution.

routes: {
  "folder/:name-:mode": "openFolder"
},

openFolder: function(routeData) {
  /* routeData is now
  {
    name: "openFolder",
    params: {
      name: "valueOfName",
      mode: "valueOfMode"
    },
    queryString: "query=string&a=b"
  }
  */
}

It could be an option that can be enabled on BB.Router.
Is it a good idea to have this functionality in base BB.Router? Or it can be an external library?

I have tried it out, and it seems to be working well, with a new set of tests cloned from current router test to make sure nothing breaks.

ntgn81@7b2c8b3

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions