I’ve just answered a question on the RequireJS mailing list and used a Gist to explain how single entry point works and how it improves the code structure and simplify dependency management.
Crossroads is basically a routing system used to map strings to functions (usually URL fragments), it acts similar to a pub/sub (event listener) but uses Regular Expressions and dynamic string patterns to identify listeners. The main feature is the robust and flexible string validation/match/parsing system.
The greatest advantage of Crossroads when compared to other similar libraries is that it is not directly tied to server requests (in case you are using it on the server-side) or to the
window.location (if you are on the browser). Another important advantages are the flexibility and the support for advanced use cases, provided by different kinds of validation rules and multiple listeners to each route. – It gives you flexibility to do any kind of action you want and doesn’t do anything you don’t ask it to do.
I hope you enjoy, contributors are welcome.
Many back-end frameworks started to adopt this technique over the past years, most of them have some sort of URL redirect that points to a “index” file or a router that decides which actions should be executed and which files should be loaded instead of having a single file for each page or section. This kind of abstraction increases flexibility a lot since you can just keep adding new pages/sections/features without having to care about the code structure, it also reduce code duplication since you don’t need to create a new file for each new page…
Flash projects have a Main Class which is the entry-point for the application and also works as the root node where all the child elements are attached (similar to the body element of an HTML file) and it helps you keep the code flow organized since you are sure that your Main Class constructor is executed before any other code, programs get easier to understand since it follows a logic order.
I’ve just released a new open source project called JS-Signals. It’s an event/message system similar to pub/sub and DOM2 Events but that doesn’t rely on strings to broadcast/subscribe to events, it has also some extra features that usually aren’t available on the other systems.
JS-Signals was heavily inspired by Robert Penner’s AS3-Signals but it is NOT a direct port, which means it has a different implementation and features. I’ve also
stolen borrowed a few ideas from Joa Ebert fork ;).
Download it and get more info at http://millermedeiros.github.com/js-signals/.
Ideas and contributors are welcome!