NobleJS/WinningJS — pull request #20 by domenic (2012-07-25 21:15:12+00:00)
Title: Add querystring support to the Navigator

This pull request is currently incomplete and needs discussion to complete. But here's the foundation.

As of these two commits, you can now pass a `state` object to `navigator.navigate`; furthermore, putting querystrings into your `href` or `data-winning-href` attributes will parse them and then pass them along to that same method.

HOWEVER, that method currently does nothing with its `state` parameter! We need to decide how to communicate the passed state to the page being shown.

It's important to remember that pages are just components that happen to have `data-winning-page` attributes. So we can leverage the component infrastructure. But, we don't (inside the navigation handler) have access to the component directly---just to its root DOM element.

Here's an idea:

* Trigger a custom DOM event, say `"show"`, on the root DOM element for the newly-shown page. It gets the state as its event object. So it'd be `$newPage.trigger("show", state)`.
* Use `data-bind` to hook this up to the view model for a given component. So it would be `data-bind="{ events: { 'show': processState }"`. Then the component's view model has a `processState` method that reconfigures itself.

This is a bit flawed because I think it puts too much responsibility on the view model and not enough on the component. Here's another idea:

* Keep the custom triggering as before. Perhaps change the event name to `"winning-page-show"` or something.
* All components who want to be pages can pass in a `processState` option to the `Presenter` constructor, which takes care of listening for our custom event on the root element and hooking it up to the supplied handler.

Hmm, getting there.