DRYing up Routing with Events

Learn how to use the DRY principle for routing with the help of events in Marionette.

Right now, our app is manually changing the URL and calling a controller action if the URL contains no fragment. However, that isn’t very DRY.“Don’t repeat yourself” is a principle of software development. We’ll end up setting route fragments and calling controller methods everywhere, which will be a nightmare to maintain.

Triggering events for changing URL

Instead, let’s leverage events, as we can see in line 6 below:

Get hands-on with 1400+ tech skills courses.