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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With