Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Google Dart web-ui @observable standalone?

I can't figure out how to use the @observable annotation/Observable class to get simple notifications when the state of an object changes.

import 'package:web_ui/observe.dart';

@observable class T{
  String x;
// what else is needed?
}

T t = new T();
observe(t, (e) => print ("Value changed"));
t.x = "Changed";

I would like to use the observables without the rest of web-ui if possible (as a substitute for backbone.js).

like image 213
mme Avatar asked Nov 04 '22 02:11

mme


1 Answers

You will need to run the dwc compiler, which looks for @observable and generates new source code that actually implements the observing. I've never tried to run the observables without Web UI, but you'll certainly need dwc to generate the correct output.

like image 136
Seth Ladd Avatar answered Nov 11 '22 00:11

Seth Ladd