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

Unified Diff: pkg/barback/lib/src/phase_input.dart

Issue 238503003: Make [Barback.getAllAssets] work when called synchronously. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 | pkg/barback/test/package_graph/get_all_assets_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/phase_input.dart
diff --git a/pkg/barback/lib/src/phase_input.dart b/pkg/barback/lib/src/phase_input.dart
index db33779ec10e3fafcf124f2099f7373cf2b08341..0f8a365ca33b495c05bacd07a1729b7f61d3db8f 100644
--- a/pkg/barback/lib/src/phase_input.dart
+++ b/pkg/barback/lib/src/phase_input.dart
@@ -38,6 +38,9 @@ class PhaseInput {
/// The asset node for this input.
AssetNode get input => _inputForwarder.node;
+ /// The subscription to [input]'s [AssetNode.onStateChange] stream.
+ StreamSubscription _inputSubscription;
+
/// A stream that emits an event whenever [this] is no longer dirty.
///
/// This is synchronous in order to guarantee that it will emit an event as
@@ -53,7 +56,8 @@ class PhaseInput {
final _onAssetPool = new StreamPool<AssetNode>.broadcast();
/// Whether [this] is dirty and still has more processing to do.
- bool get isDirty => _transforms.any((transform) => transform.isDirty);
+ bool get isDirty => (input.state.isDirty && !input.deferred) ||
+ _transforms.any((transform) => transform.isDirty);
/// A stream that emits an event whenever any transforms that use [input] as
/// their primary input log an entry.
@@ -62,13 +66,20 @@ class PhaseInput {
PhaseInput(this._phase, AssetNode input, this._location)
: _inputForwarder = new AssetForwarder(input) {
- input.whenRemoved(remove);
+ _inputSubscription = input.onStateChange.listen((state) {
+ if (state.isRemoved) {
+ remove();
+ } else if (state.isAvailable) {
+ if (!isDirty) _onDoneController.add(null);
+ }
+ });
}
/// Removes this input.
///
/// This marks all outputs of the input as removed.
void remove() {
+ _inputSubscription.cancel();
_onDoneController.close();
_onAssetPool.close();
_onLogPool.close();
« no previous file with comments | « no previous file | pkg/barback/test/package_graph/get_all_assets_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698