GeppettoJS / backbone.geppetto

Bring your Backbone applications to life with an event-driven Command framework.
http://geppettojs.github.com/backbone.geppetto/
MIT License
203 stars 28 forks source link

Geppetto and Routing #15

Closed mtsr closed 11 years ago

mtsr commented 11 years ago

Hey,

So while I'm working on a prototype using Geppetto, I'm playing around with a clean way to do routing and everything that goes with it. Some thoughts:

Right now I have the following:

It feels a little convoluted, so it may need simplification. On the other hand I'd like it the solution to be generic enough that I can use it in a variety of situations. (I could put some of this in a gist to show how it works exactly, if helpful).

A related issue I'm running into is updating the models for for example my menu items in reaction to a route event from the backbone router. It's difficult to make this generic since only parameters are passed on by the router, but the actual fragment is not. So it's not easy to have one function handle all route events.

mtsr commented 11 years ago

I made some changes to backbone routing, having it pass the fragment and route to the callbacks and eventlisteners. Also adding named parameters in the most generic possible way, by adding them to regular expression routes using XRegExp. I guess it would be possible to expand the backbone specific syntax a bit with this, but I like regular expressions, so meh.

But with these changes, the route specific commands actually work really well, since they now get an object with all the route parameters, the fragment and the route.

The only doubt I have at the moment is whether the NavigateCommand is necessary, as it still doesn't do anything much. But I guess I prefer commands to be the only one to touch the context (and like models, the router lives on the context in my app).

mtsr commented 11 years ago

I'd still be interested in feedback from other users, but my problem is solved for now, so I'm closing the issue.