Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL param names are lost : route handler should get param object with names as fields #144

Open
visionscaper opened this issue Feb 10, 2016 · 0 comments

Comments

@visionscaper
Copy link

Hello,

I'm interested in using crossroads.js, but unfortunately I can't use it as is, because crossroads seems to throw away the names of the URL parameters. This, IMHO is a fundamental flaw.

Example:

This is how you are suppose to use Crossroads.js:

crossroads.addRoute('/news/{id}/:date:', function(id, date) {
  console.log(id +' - '+ date);
});

I can't define my route handlers like that, because I need to forward the URL parameters (e.g. id and date) without knowing what they are. So I need something like this:

crossroads.addRoute('/news/{id}/:date:', function(params) {
  goToState(stateHandlingThisRoute, params); //params === { id : <some id>,  data : <some date> }
});

Only a state named stateHandlingThisRoute knows what to expect in params; at the level where I add the handler, I don't know!

So, if the above is not possible, Crossroads can't be used in a larger architecture where the URL parameters are still an abstract concept. Maybe I missed something that makes this abstract use possible. If so, please let me know! If not, this would need to be fixed IMO, to make crossroads applicable as a routing library in more complex routing systems.

-- Freddy Snijder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant