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

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

Issue 21446002: Add events in barback to bubble up the dirty bit. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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
Index: pkg/barback/lib/src/transform_node.dart
diff --git a/pkg/barback/lib/src/transform_node.dart b/pkg/barback/lib/src/transform_node.dart
index 863bac53e4991b346b06a3d982c5ed72b99ecf61..1decef7ec29157d487476b5cca314a4a017e284a 100644
--- a/pkg/barback/lib/src/transform_node.dart
+++ b/pkg/barback/lib/src/transform_node.dart
@@ -45,6 +45,15 @@ class TransformNode {
/// The controllers for the asset nodes emitted by this node.
var _outputControllers = new Map<AssetId, AssetNodeController>();
+ /// A stream that emits an event whenever this transform becomes dirty and
+ /// needs to be re-run.
+ ///
+ /// This may emit events when the transform was already dirty or while
+ /// processing transforms. Events are emitted synchronously to ensure that the
+ /// dirty state is thoroughly propagated as soon as any assets are changed.
+ Stream get onDirty => _onDirtyController.stream;
+ final _onDirtyController = new StreamController.broadcast(sync: true);
+
TransformNode(this.phase, this.transformer, this.primary) {
_primarySubscription = primary.onStateChange.listen((state) {
if (state.isRemoved) {
@@ -80,6 +89,7 @@ class TransformNode {
for (var controller in _outputControllers.values) {
controller.setDirty();
}
+ _onDirtyController.add(null);
}
/// Applies this transform.

Powered by Google App Engine
This is Rietveld 408576698