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

Router.go takes an unordered object, but arguments depends on ordering #5

Open
Karolusrex opened this issue Dec 17, 2015 · 6 comments
Assignees
Labels

Comments

@Karolusrex
Copy link
Contributor

In Javascript, there is no guarantee of ordering of object properties. The ordering is crucial inside the controllers, so I would consider to make the arguments as an array.

@Karolusrex
Copy link
Contributor Author

Essentially, it is not safe to pass more than one argument as I see it

@Karolusrex
Copy link
Contributor Author

After reading a bit I saw that all browsers support ordering, although not explicitly supported by the specification. So this point might not be that urgent

@Karolusrex
Copy link
Contributor Author

Solution with different syntax to solve this problem:

Instead of router.go(.., .., {param1: a, param2: b}), we can go for router.go(.., .., [['param1', a], ['param2', b]})

The router.go function can then create a new Map() of this last argument which is ordered by nature

@trbm1
Copy link

trbm1 commented Jan 31, 2016

And maybe introducing a special parameter resolver to ensure correct formatting with the router. Like:
[['param1', a], ['param2', b]] = ParameterHelper.resolve({ param1: a, param2: b});

@trbm1
Copy link

trbm1 commented Feb 2, 2016

Suggestion 2: using ES7 decorators. E.g.

@param.order('parm1', 'parm2')
    someControllerFunction(parm1, parm2) {
    }

and have either the query map to the specified order OR passing a simple JSON object to the router.go function. Making router.go as simple as:

router.go('someControllerFunction', 34,  'fff');

@tjclement
Copy link
Contributor

I'm not too excited about the semantics of those solutions, but automatically parsing the correct argument order through reflection still seems super expensive: http://jsperf.com/function-tostring-performance.

Let's keep this parked for a little while longer.

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

No branches or pull requests

3 participants