Using websockets/Server sent events with Angular dart -
i trying use angular dart websockets/server sent events , not find documentation/examples (there angularjs seems different such things). few things tried did not work.
does know how this?
here 1 version of tried , error:
@ngcontroller ( selector: "acdistribution", publishas : "dstbn") class acdstbncontroller{ list <wtdpres> distbn; void updatedstbn(list<wtdpres> newdstbn){ distbn = newdstbn; } final dstbnsrc = new eventsource("../dstbns") ..onmessage.listen((event){ list wps = json.decode(event.data); list <wtdpres> newdistbn = wps.map((wp) => new wtdpres.fromjson(wp)); updatedstbn(newdistbn); }); }
the error got in pub build was:
web/provingground.dart:55:5: 'updatedstbn' available in instance methods. updatedstbn(newdistbn); ^^^^^^^^^^^
there limitations on can on initializers final fields.
can try put code inside constructor
var dstbnsrc; acdstbncontroller() { dstbnsrc = new eventsource("../dstbns") ..onmessage.listen((event){ list wps = json.decode(event.data); list <wtdpres> newdistbn = wps.map((wp) => new wtdpres.fromjson(wp)); updatedstbn(newdistbn); }); }
Comments
Post a Comment