olivernn / davis.js

RESTful degradable JavaScript routing using pushState
http://davisjs.com
532 stars 58 forks source link

Node style events #20

Closed tj closed 13 years ago

tj commented 13 years ago

.on / .emit and some refactoring

olivernn commented 13 years ago

I'm on the fence about this, the node style event methods are certainly shorter but are possibly less familiar to a client side javascript developer. I'd like to only have one set of methods for binding and triggering events in the end to keep the api focused.

You're right about the events module currently being shared between apps. I don't think this is a huge issue since I'm not really sure why you would need multiple apps on the same page.

This then suggests that perhaps the App object should be a singleton, enforcing the one app per page and sidestepping any unexpected issues that could arise by creating more than one app per page.

tj commented 13 years ago

for testing etc I think it's always a good idea to spawn from a prototype, so I think we're good there, but yeah probably not a huge issue

tj commented 13 years ago

let me know if you're not interested in all this stuff. I probably have slightly different goals, I just want a really tiny router really, but if I fork I'll (of course) give you attribution

olivernn commented 13 years ago

I'm interested - just been real busy this last week! I'm aiming to get a 0.7 release out this week which will include these changes.

olivernn commented 13 years ago

I've pushed some of these changes in the next branch.

I decided not to add the on and emit event methods. Although they are shorter than trigger and bind I don't think it is worth either changing the api or having two sets of methods to do the same thing.

I also moved the functionality of the davis method into the main Davis function, so that it creates and returns an automatically started instance of an app. This prevents us from polluting the global namespace with another function.

There are a few more tweaks that I'm going to make before merging this into master but thought you'd be interested in the latest changes.

tj commented 13 years ago

sounds good!

olivernn commented 13 years ago

Hey I've just pushed a new release incorporating these changes, as well as a few others. Let me know if there are any issues.

Thanks again for the changes to the build tools, much faster and more portable using make instead of rake.

tj commented 13 years ago

awesome! good stuff man