The Eisenberg Effect

Preparing for Durandal NextGen

Introduction

user

Rob Eisenberg

Rob is an internationally recognized UI development expert. He is the creator of Durandal and Caliburn.Micro. Rob currently works on the AngularJS 2.0 Core Team building the future.


durandal

Preparing for Durandal NextGen

Posted by Rob Eisenberg on .
Featured

durandal

Preparing for Durandal NextGen

Posted by Rob Eisenberg on .

Current development of Durandal NextGen is progressing well. It's a major set of breaking changes from the current 2.x series implementation, but it's going to result in greater power, better performance, enhanced tooling and many other benefits.

Is NextGen For Me?

If you are currently using Durandal 2.x, you may be wondering if you should plan to migrate when the NextGen implementation becomes available. Here are a couple of facts about the NextGen which you should consider:

The new version will be the same Durandal in spirit, but there will be many implementation changes and a good deal of work to migrate code for existing apps. If your current app needs to support non-Evergreen browsers, then you won't be able to migrate to NextGen until you can lift that restriction.

Don't fear. If you can't or don't want to migrate to NextGen, be advised that the current 2.x version will be maintained for a long time.

Recommendations

If you plan to migrate to NextGen, there are a few things you can do today to make that transition easier on yourself.

The Observable Plugin

In the 2.0 release of Durandal, we introduced the observable plugin. This plugin allows you to use "Plain Old JavaScript Objects" for models and view-models. Behind the scenes, the plugin will automatically convert a normal JS object into an observable one by creating hidden Knockout observables and configuring getters and setters on your object. The result is that you can have normal properties on your objects and you can remove all those extra function calls and parentheses from your JS code and your binding expressions. Your code will be more maintainable and easier to read. Your JS objects and binding syntax will also be much closer to NextGen, so this will be one less thing you will have to change throughout your app. You can read more about the plugin and see how to get started here.

Knockout.Punches

Knockout.Punches is a nice plugin to Knockout which extends Knockout's binding system with some convenient new syntax. There are three features in particular that are important:

  • Embedded Text Bindings (aka text interpolation)
  • Embedded Attribute Bindings (aka attribute interpolation)
  • Text Filters

These changes will make your HTML binding expressions much more like Durandal NextGen. They'll also simplify your bindings and make things more readable overall.

Classes

Durandal NextGen will bring some new module and dependency injection concepts. While you will be able to use any JavaScript object creation patterns with NextGen, there will be particular power in using class-ish patterns. This is particularly useful for view-model and controller-style modules. In general, avoid singleton object modules and prefer function modules.

Languages like TypeScript or the use of the Traceur Compiler, which both align heavily with ES6, will put you in a solid position for moving your codebase forward.

Summary

Plan for Durandal NextGen if you support only Evergreen browsers and can handle switching templating engines and other breaking changes. To minimize the porting effort, you can make some strategic moves now by enabling the observable plugin, using Knockout.Punches and adopting a class-ish approach to creating modules. If you can't or don't want to migrate to NextGen, don't sweat it! There will be ongoing support for 2.x.

user

Rob Eisenberg

http://www.bluespire.com

Rob is an internationally recognized UI development expert. He is the creator of Durandal and Caliburn.Micro. Rob currently works on the AngularJS 2.0 Core Team building the future.