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

Side by Side Diff: lib/src/asset/asset_node.dart

Issue 1947773002: Fix all strong-mode warnings. (Closed) Base URL: git@github.com:dart-lang/barback@master
Patch Set: Code review changes Created 4 years, 7 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 | « CHANGELOG.md ('k') | lib/src/asset/asset_set.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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library barback.asset.asset_node; 5 library barback.asset.asset_node;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import '../errors.dart'; 9 import '../errors.dart';
10 import '../graph/transform_node.dart'; 10 import '../graph/transform_node.dart';
11 import '../utils.dart';
12 import 'asset.dart'; 11 import 'asset.dart';
13 import 'asset_id.dart'; 12 import 'asset_id.dart';
14 13
15 /// Describes the current state of an asset as part of a transformation graph. 14 /// Describes the current state of an asset as part of a transformation graph.
16 /// 15 ///
17 /// An asset node can be in one of three states (see [AssetState]). It provides 16 /// An asset node can be in one of three states (see [AssetState]). It provides
18 /// an [onStateChange] stream that emits an event whenever it changes state. 17 /// an [onStateChange] stream that emits an event whenever it changes state.
19 /// 18 ///
20 /// Asset nodes are controlled using [AssetNodeController]s. 19 /// Asset nodes are controlled using [AssetNodeController]s.
21 class AssetNode { 20 class AssetNode {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 Future<AssetState> whenStateChanges() { 107 Future<AssetState> whenStateChanges() {
109 var startState = state; 108 var startState = state;
110 return _waitForState((state) => state != startState, (state) => state); 109 return _waitForState((state) => state != startState, (state) => state);
111 } 110 }
112 111
113 /// Calls [callback] as soon as the node is in a state that matches [test]. 112 /// Calls [callback] as soon as the node is in a state that matches [test].
114 /// 113 ///
115 /// [callback] is called synchronously if this is already in such a state. 114 /// [callback] is called synchronously if this is already in such a state.
116 /// 115 ///
117 /// The return value of [callback] is piped to the returned Future. 116 /// The return value of [callback] is piped to the returned Future.
118 Future _waitForState(bool test(AssetState state), 117 Future/*<T>*/ _waitForState/*<T>*/(bool test(AssetState state),
119 callback(AssetState state)) { 118 /*=T*/ callback(AssetState state)) {
120 if (test(state)) return syncFuture(() => callback(state)); 119 if (test(state)) return new Future.sync(() => callback(state));
121 return onStateChange.firstWhere(test).then((_) => callback(state)); 120 return onStateChange.firstWhere(test).then((_) => callback(state));
122 } 121 }
123 122
124 AssetNode._(this.id, this._transform, this._origin) 123 AssetNode._(this.id, this._transform, this._origin)
125 : _state = AssetState.RUNNING; 124 : _state = AssetState.RUNNING;
126 125
127 AssetNode._available(Asset asset, this._transform, this._origin) 126 AssetNode._available(Asset asset, this._transform, this._origin)
128 : id = asset.id, 127 : id = asset.id,
129 _asset = asset, 128 _asset = asset,
130 _state = AssetState.AVAILABLE; 129 _state = AssetState.AVAILABLE;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 273
275 /// Whether this state is [AssetState.RUNNING]. 274 /// Whether this state is [AssetState.RUNNING].
276 bool get isDirty => this == AssetState.RUNNING; 275 bool get isDirty => this == AssetState.RUNNING;
277 276
278 final String name; 277 final String name;
279 278
280 const AssetState._(this.name); 279 const AssetState._(this.name);
281 280
282 String toString() => name; 281 String toString() => name;
283 } 282 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/asset/asset_set.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698