Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(929)

Unified Diff: sky/sdk/lib/framework/components2/animated_component.dart

Issue 1171273002: Move AnimatedComponent away from mirrors and towards a callback-based setter. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/sdk/lib/framework/animation/animated_value.dart ('k') | sky/sdk/lib/framework/components2/drawer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/framework/components2/animated_component.dart
diff --git a/sky/sdk/lib/framework/components2/animated_component.dart b/sky/sdk/lib/framework/components2/animated_component.dart
index 79aabef0e08cc9ad7dfab02ea28e3717c59da8c0..d1dada90dbfeab2f8efe483c34c8bcdb11e334fe 100644
--- a/sky/sdk/lib/framework/components2/animated_component.dart
+++ b/sky/sdk/lib/framework/components2/animated_component.dart
@@ -4,32 +4,23 @@
import '../animation/animated_value.dart';
import '../fn2.dart';
-import 'dart:mirrors';
+import 'dart:async';
-abstract class AnimatedComponent extends Component {
- AnimatedComponent({ Object key }) : super(key: key, stateful: true);
-
- var _debugAnimatedFields = new Set<Symbol>();
- bool _debugIsNotYetAnimated(Symbol s) {
- return _debugAnimatedFields.add(s);
- }
+typedef void SetterFunction(double value);
- animateField(AnimatedValue value, Symbol symbol) {
- // TODO(rafaelw): Assert symbol is present on |this|, is private and
- // is over the same parameterized type as the animated value.
- var mirror = reflect(this);
- var subscription;
+abstract class AnimatedComponent extends Component {
- assert(_debugIsNotYetAnimated(symbol));
- mirror.setField(symbol, value.value);
+ AnimatedComponent({ Object key }) : super(key: key, stateful: true);
+ animate(AnimatedValue value, SetterFunction setter) {
+ setter(value.value);
+ StreamSubscription<double> subscription;
onDidMount(() {
subscription = value.onValueChanged.listen((_) {
- mirror.setField(symbol, value.value);
+ setter(value.value);
scheduleBuild();
});
});
-
onDidUnmount(() {
if (subscription != null) {
subscription.cancel();
@@ -37,4 +28,5 @@ abstract class AnimatedComponent extends Component {
}
});
}
+
}
« no previous file with comments | « sky/sdk/lib/framework/animation/animated_value.dart ('k') | sky/sdk/lib/framework/components2/drawer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698