autonotify_observe 1.0.0+14

  • Installing
  • Versions
  • 44

Auto notify support for (yet to be released) polymer-dart 1.0

a.k.a. : get rid of all those fancy set, add, remove, etc. calls

the problem

In polymer 1.0 you have to call a bunch of API (set and list accessor methods) on the polymer component whenever you have to apply a change on the model instead of changing the model directly. To make things worse if you have two or more independent components, for example two different views of the same model that are not inheriting the model one from the other by means of binding constructs (i.e. {{ }} or [[ ]]), then you will have to call those API on each of component.

Other then being very annoying this makes nearly impossible to follow consolidated patterns like MVC when building an app using vanilla polymer 1.0 : infact the controller (C) should always interact directly with the view (V) to update the model (M).

The opposite is true for polymer before 1.0 and that's one of the reason many appreciated that framework even though it was slower and less browser independent.

enters autonotify

This package will add support for autonotify in polymer-dart 1.0, making it possible to write your code more or less in the same way you used to do with previous polymer version.

how it works

You just have to annotate properties with @observable and extend/mixin the familiar Observable mixin, exactly like for previous polymer version, and polymer_autnotify will take care of calling polymer accessor API automatically for you.

The model

Any class you intend to use as a model object should be extend or mixin Observable. Any property you want to be available for unidirectional or bidirectional binding should be annotatated by @observable. For example:

import "package:observe/observe.dart";

class MyModel extends Observable {
 @observable String field1;
 @observable AnotherModel field2;

class AnotherModel extends Object with Observable {
 @observable String field3;

The element

Your polymer element should be defined as usual and mixin both AutonotifyBehavior and Observable, properties should be annotated both with @observable and @property (or @Property(...)). Use ObservableList for mutable collections :

import "package:polymer_autonotify/polymer_autonotify.dart" show AutonotifyBehavior;

class MyElement extends PolymerElement with AutonotifyBehavior,Observable {
 @observable @property List<MyModel> prop1  = new ObservableList();
 @observable @property String prop2;
 MyElement.created() : super.created();

 void doChange1([_,__]) {
  prop1.add(new MyModel());
 void doChange2([ev,__]) {
   new DomRepeatModel.fromEvent(convertFromJs(ev))["item"].field2="hello!";


Notice : you do not have to call list API accessor neither set method, just update the model and the bidings will get updated, but this should not be a big surprise after all it is all this package is all about.

using the transformer

To enable observability you have to add the autonotify_observe transformer to all you dart project that are using it (both your main application and any other libraries that your main application depends on and that will define model classes and/or polymer elements).

The transformer can be used in place of the polymer transformer, in that case your pubspec.yaml will be simple and like this:

 - autonotify_observe:
    - web/index.html


(entry points are those defined by the polymer transformer, see polymer documentations for that).

If you prefer to use the original polymer transformer then you can (as a matter of fact at the moment there is no reason for doing that, but anyway the choice is yours). In this case your pubspec.yaml should be like this:

 - autonotify_observe
 - polymer:
    - web/index.html


Just avoid to specify any entry_point for the autonotify_observe and enlist that transformer before polymer one.

As already stated before if your main app imports models classes or elements from other packages then you should declare the autonotify_observe also in the corresponding pubspec.yaml, like this:

 - autonotify_observe


autonotify_observe requires a modified observe library that you can find here. You do not have to explicitly declare a dependency because you will implicitly get it as a dependency of this package.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  autonotify_observe: "^1.0.0+14"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

      import 'package:autonotify_observe/autonotify_observe.dart';
Version Uploaded Documentation Archive
1.0.0+14 Jul 24, 2017 Go to the documentation of autonotify_observe 1.0.0+14 Download autonotify_observe 1.0.0+14 archive
1.0.0+10 Jul 18, 2016 Go to the documentation of autonotify_observe 1.0.0+10 Download autonotify_observe 1.0.0+10 archive
1.0.0+8 Jun 13, 2016 Go to the documentation of autonotify_observe 1.0.0+8 Download autonotify_observe 1.0.0+8 archive
1.0.0+7 Jan 14, 2016 Go to the documentation of autonotify_observe 1.0.0+7 Download autonotify_observe 1.0.0+7 archive
1.0.0+6 Jan 12, 2016 Go to the documentation of autonotify_observe 1.0.0+6 Download autonotify_observe 1.0.0+6 archive
1.0.0+5 Jan 12, 2016 Go to the documentation of autonotify_observe 1.0.0+5 Download autonotify_observe 1.0.0+5 archive
1.0.0+4 Jan 10, 2016 Go to the documentation of autonotify_observe 1.0.0+4 Download autonotify_observe 1.0.0+4 archive
1.0.0+3 Jan 10, 2016 Go to the documentation of autonotify_observe 1.0.0+3 Download autonotify_observe 1.0.0+3 archive
1.0.0+2 Jan 9, 2016 Go to the documentation of autonotify_observe 1.0.0+2 Download autonotify_observe 1.0.0+2 archive
1.0.0+1 Jan 9, 2016 Go to the documentation of autonotify_observe 1.0.0+1 Download autonotify_observe 1.0.0+1 archive

All 12 versions...


We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
15 / 100
Code health derived from static analysis. [more]
69 / 100
Reflects how tidy and up-to-date the package is. [more]
75 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:autonotify_observe/autonotify_observe.dart.


  • Maintain

    Changelog entries help clients to follow the progress in your code.

  • Use constrained dependencies.

    The pubspec.yaml contains 3 dependencies without version constraints. Specify version ranges for the following dependencies: barback, polymer, polymer_autonotify.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 error 1 hint.

    Strong-mode analysis of lib/transformer.dart failed with the following error:

    line: 32 col: 17
    The element type 'PolymerTransformerGroup' can't be assigned to the list type 'Transformer'.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use autonotify_observe.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0
analyzer >=0.29.11 <0.32.0 0.29.11 0.32.1
barback any 0.15.2+16
observe 0.13.1+reflectable.4 0.13.1+reflectable.4 0.15.1
polymer >=1.0.0-rc.12 1.0.0-rc.19
polymer_autonotify >=1.0.0+3 1.0.0+3
Transitive dependencies
args 0.13.7 1.4.3
async 2.0.7
charcode 1.1.1
cli_util 0.0.1+2 0.1.3
code_transformers 0.5.1+3 0.5.1+5
collection 1.14.10
convert 2.0.1
crypto 2.0.5
csslib 0.14.4
dart_style 0.2.16 1.1.0
glob 1.1.5
html 0.13.3+1
initialize 0.6.2+7
isolate 1.1.0 2.0.1
logging 0.11.3+1
meta 1.1.5
package_config 1.0.3
path 1.6.1
plugin 0.2.0+2
polymer_interop 1.0.0-rc.10
pool 1.3.5
reflectable 1.0.3 2.0.1
source_maps 0.10.5
source_span 1.4.0
stack_trace 1.9.2
string_scanner 1.0.2
typed_data 1.1.5
utf 0.9.0+4
watcher 0.9.7+8
web_components 0.12.5
when 0.2.0
which 0.1.3
yaml 2.1.14
Dev dependencies
test any