dart - When my future completes, how do I notify the observed variable? -


my template (item_view.html) references variable (map item) that's getter it's defined in viewmodel.

in item_view.html, things like:

<h1>{{item['subject']}}</h1> 

in item_view.dart, item is:

  @observable map item => toobservable(viewmodel.itemviewmodel.item); 

note it's referencing observed map item in itemviewmodel below.

the mainviewmodel has getter itemviewmodel:

@observable itemviewmodel itemviewmodel {     // code determine item model return.     // ...     return itemviewmodels[id];   } 

and finally, itemviewmodel gets item, , should populating item results.

class itemviewmodel extends observable {   final app app;   @observable map item = toobservable({});    itemviewmodel(this.app) {     getitem();   }    void getitem() {     ...     // todo: completes later, , item changes aren't being observed!     f.child('/items/' + decodeditem).onvalue.first.then((e) {        item['subject'] = // ...and on.     ... 

the problem seems because listener completes in future, it's not updating @observable map item , not reflecting in template.

am missing toobservable() somewhere? need use notifychange() (i'm not sure when use , can't find examples)?

this line doesn't make sense

@observable map item => toobservable(viewmodel.itemviewmodel.item); 

item observablebecause made observable line

@observable map item = toobservable({});  

when assign map item have ensure make observable before assigning or make item final, exception when try reassign else. can add/remove items can sure item stays observable map.

@observable final map item = toobservable({});  

update

@computedproperty('viewmodel.itemviewmodel.item') @observable map item => toobservable(viewmodel.itemviewmodel.item); 

http://www.dartdocs.org/documentation/polymer/0.12.0/index.html#polymer/polymer.computedproperty#id_computedproperty-


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -