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

Side by Side Diff: sky/sdk/lib/framework/components2/animated_component.dart

Issue 1174023003: Remove one more use of mirrors: Components now have to explicitly sync their fields. (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 unified diff | Download patch
« no previous file with comments | « sky/examples/stocks2/lib/stock_row.dart ('k') | sky/sdk/lib/framework/components2/button.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import '../animation/animated_value.dart'; 5 import '../animation/animated_value.dart';
6 import '../fn2.dart'; 6 import '../fn2.dart';
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 typedef void SetterFunction(double value); 9 typedef void SetterFunction(double value);
10 10
11 abstract class AnimatedComponent extends Component { 11 abstract class AnimatedComponent extends Component {
12 12
13 AnimatedComponent({ Object key }) : super(key: key, stateful: true); 13 AnimatedComponent({ Object key }) : super(key: key, stateful: true);
14 14
15 void syncFields(AnimatedComponent source) { }
16
15 animate(AnimatedValue value, SetterFunction setter) { 17 animate(AnimatedValue value, SetterFunction setter) {
16 setter(value.value); 18 setter(value.value);
17 StreamSubscription<double> subscription; 19 StreamSubscription<double> subscription;
18 onDidMount(() { 20 onDidMount(() {
19 subscription = value.onValueChanged.listen((_) { 21 subscription = value.onValueChanged.listen((_) {
20 setter(value.value); 22 setter(value.value);
21 scheduleBuild(); 23 scheduleBuild();
22 }); 24 });
23 }); 25 });
24 onDidUnmount(() { 26 onDidUnmount(() {
25 if (subscription != null) { 27 if (subscription != null) {
26 subscription.cancel(); 28 subscription.cancel();
27 subscription = null; 29 subscription = null;
28 } 30 }
29 }); 31 });
30 } 32 }
31 33
32 } 34 }
OLDNEW
« no previous file with comments | « sky/examples/stocks2/lib/stock_row.dart ('k') | sky/sdk/lib/framework/components2/button.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698