polymer_autonotify 0.0.4-SNAPSHOT polymer_autonotify: ^0.0.4-SNAPSHOT copied to clipboard
auto notify support for Polymer 1.0
Auto notify support for (yet to be released) polymer 1.0 #
This package will add support for autonotify in polymer-dart 1.0.
Just add the dependency and add the mixins PolymerAutoNotifySupportJsBehavior
and PolymerAutoNotifySupportBehavior
to your PolymerElement
.
Annotate property with @observable
(just like in the previous polymer version).
notes #
Last version works only with modified observe
you can find here, until the official one gets ported to reflectable or that branch gets merged.
using the transformer (optional but recommended) #
Because observe
(the modified one to use reflectable
) and polymer-dart
use different mirror systems to make an object usable both by polymer and autonotify you will have to annotate it twice (and make it mixin/extend both JsProxy
AND Obserable
).
For example:
class ThatBeautifulModelOfMine extends Observable with JsProxy {
@reflectable @observable String field1;
@reflectable @observable String field2;
}
This can be annoying. Expecially if you have many of those classes around that were already annotated for observe
.
But don't worry! polymer_autonotify
will come in help with a nice transformer that should be run before observe
transformer and that will add polymer-dart
mixin and annotations for you on object already prepared for observe
.
This way previous users of observe
(that already have their object annotated for it) will have nothing to change to use their code with the new polymer-dart
and polymer-autonotify
.
In the example before one should only write:
class TheBeautifulModelOfMine extends Observable {
@observable String field1;
@observable String field2;
}
If you want to use it your main pubspec.yaml
should appear like this :
...
- web_components:
entry_points:
- web/index.html
- polymer_autonotify
- observe
- reflectable:
entry_points:
- web/index.dart
...
observe
and polymer_autonotify
transformer should also be placed in all your imported packages that exports polymer
your custom components using autonotify
and exporting models.