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

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: Close TransformNode.onDirty. Created 7 years, 4 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 | « pkg/barback/lib/src/stream_pool.dart ('k') | pkg/barback/test/stream_pool_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9d8bda1ff4a1eda07104162ad3275dcf1c3b5081 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) {
@@ -63,6 +72,7 @@ class TransformNode {
/// valid even if its primary input still exists.
void remove() {
_isDirty = true;
+ _onDirtyController.close();
_primarySubscription.cancel();
for (var subscription in _inputSubscriptions.values) {
subscription.cancel();
@@ -80,6 +90,7 @@ class TransformNode {
for (var controller in _outputControllers.values) {
controller.setDirty();
}
+ _onDirtyController.add(null);
}
/// Applies this transform.
« no previous file with comments | « pkg/barback/lib/src/stream_pool.dart ('k') | pkg/barback/test/stream_pool_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698