Autonotify support

Autonotify is a nice native feature of oldest dart-polymer (< 1.0) version that was since version 1.0.

The package autonotify_observe allowed to restore this feature for dart-polymer 1.x.

autonotify_observe is an nice package but had some issues:

Since v. 0.8.5 polymerize has a built in support for autonotify. All you have to do is to mixin the AutonotifyBehavior and voilà!

In particular :

Autonotify support for polymerize leverages the Proxy support of modern browser to implement object observability. So it doesn’t need to modify your classes and for that reason it is much faster than before.

Other than that an observed version of a property is created as soon as it is read from an already observed object. Thus observation is implmented “on demand” as soon as it is needed.

See the todo_demo for an example on how to use autonotify in polymerize.

But What is this autonotify after all ?

Ok, ok. For people who doesn’t know it here’s an explanation.

Polymer requires you to inform the framework when a property is modified in order to update the view. This is accomplished with the notify API.

For example if the propertiy name of the field user gets changed you have to inform polymer calling notifyPath(''). In the same way this holds for element in an list:

Actually for all the first level properties this is automatically done for you by polymer by means of replacing all the properties with dedicated accessors that will call notifyPath for you. And there are cases when this is done even for deeper properties (when they are bound to other components properties that has been declared with the notify flag to true - annotated with @Notify in polymerize).

But : this doesn’t holds generally but more importantly if you change the property outside the context of your component it doesn’t get automatically notified (see autonotify_observe for more explanations).

With autonotify support you can have all your properties automatically notified for you (hence the name) at the cost of simply adding a mixin (AutonotifyBehavior) to your element declaration. This in practice means that you can forget all about the notify API and the list accessors API too.

This greatly simplify working with polymer and allows to implement a realt MVC pattern in your polymer based application.