My Minimal Client-Side Router based on Director.js

There are at least thirty-two different ways to initialize a client-side Director.js routing object. I think I’m happy that I ran into a bunch of issues toying around with the more advanced modes because it got me annoyed enough to consider how little of it I could use and get away with.

Anyway, I’ve wrapped up a tiny CoffeeScript class that encapsulates a contained instance of a Director.js client-side router and provides an extremely simple (and importantly predictable) callback on route change. Nothing fancy by design: the main application will take car of figuring out what the route means. There’s no recursion, assistance unboxing parameters, asynchronous route processing or any of that.

The Coffeescript class declaration is checked into the Encapsule Schema repo here:

This class is now integrated into Schema bootstrapper  and is loaded essentially first affording an opportunity for the bootstrapper to parse the route, grab for example, debug flags or whatever, and then continue through boot. Once boot completes, the main application logic takes over the single route change callback exposed by class.

You can see this action in tonight’s Schema test build (I’ve left my debug console up in this build so you can see what’s going on):

About Chris Russell
This entry was posted in Internet, Open Source, Software and tagged , , , . Bookmark the permalink.

Comment on this article

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s