d4f / backbone-highway

Routing Backbone with style \o/
MIT License
19 stars 5 forks source link

Support query parameters #31

Closed bpatram closed 6 years ago

bpatram commented 7 years ago

Add another option to the go function for a query object (for defining query parameters) and pass the query object along to the route action.

It is already built into urlComposer https://github.com/RasCarlito/url-composer#usage

Example:

history.route({
  name: 'my-route',
  path: 'items/:id',
  action(state) {
    console.log(state.params, state.query);
    state.resolve();
  }
});

history.go({ name: 'my-route', params: { id: 1 }, query: { search: 'foo' });
// items/1?search=foo
bpatram commented 7 years ago

@toddbluhm It seems you've added query param support in your fork! Are you planning on submitting a PR?

via https://github.com/toddbluhm/backbone-highway/commit/1dcac5d9ebd371b5dabe199fc25c489b443d4e96

toddbluhm commented 7 years ago

Yeah I did add query param support. I also changed few other things and made the lib more promise compliant. I can see about PR'ing the Query Param stuff though if you like?

ghost commented 7 years ago

Hi @toddbluhm and @bpatram ! Thanks for your interest in this piece of code :)

I have been working on this router for years and it has seen many changes over time. The support for query parameters is a nice add and yes my url-composer lib does support it already.

@toddbluhm if you already have an implementation in your fork i would be more than happy to integrate it via a PR.

Cheers

ghost commented 7 years ago

@toddbluhm I've checked out the modifications in your fork, very nicely done :)

toddbluhm commented 7 years ago

I will go ahead then and parse out my changes and submit some separate PRs for them.

My current list of changes is the following:

ghost commented 7 years ago

Awesome :metal: