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

Unified Diff: sky/sdk/lib/widgets/animated_component.dart

Issue 1216533003: Remove the pointless second argument to animate() in AnimatedValue. (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 | « no previous file | sky/sdk/lib/widgets/drawer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/widgets/animated_component.dart
diff --git a/sky/sdk/lib/widgets/animated_component.dart b/sky/sdk/lib/widgets/animated_component.dart
index 23573bb95efbd58039b05a0e3f658a0e0c8038d9..025e3a4fb3f2d06c06648a306ab24a115692144b 100644
--- a/sky/sdk/lib/widgets/animated_component.dart
+++ b/sky/sdk/lib/widgets/animated_component.dart
@@ -7,12 +7,9 @@ import 'dart:async';
import '../animation/animated_value.dart';
import 'basic.dart';
-typedef void SetterFunction(double value);
-
class _AnimationEntry {
- _AnimationEntry(this.value, this.setter);
+ _AnimationEntry(this.value);
final AnimatedValue value;
- final SetterFunction setter;
StreamSubscription<double> subscription;
}
@@ -24,16 +21,19 @@ abstract class AnimatedComponent extends Component {
List<_AnimationEntry> _animatedFields = new List<_AnimationEntry>();
- animate(AnimatedValue value, SetterFunction setter) {
+ watch(AnimatedValue value) {
assert(!mounted);
- setter(value.value);
- _animatedFields.add(new _AnimationEntry(value, setter));
+ // TODO(ianh): we really should assert that we're not doing this
+ // in the constructor since doing it there is pointless and
+ // expensive, since we'll be doing it for every copy of the object
+ // even though only the first one will use it (since we're
+ // stateful, the others will all be discarded early).
+ _animatedFields.add(new _AnimationEntry(value));
}
void didMount() {
for (_AnimationEntry entry in _animatedFields) {
entry.subscription = entry.value.onValueChanged.listen((_) {
- entry.setter(entry.value.value);
scheduleBuild();
});
}
« no previous file with comments | « no previous file | sky/sdk/lib/widgets/drawer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698