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

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

Issue 249183005: Move common streams in barback to their own class. (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 | « pkg/barback/lib/src/group_runner.dart ('k') | pkg/barback/lib/src/phase.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/node_streams.dart
diff --git a/pkg/barback/lib/src/node_streams.dart b/pkg/barback/lib/src/node_streams.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7b6632fae28503580b68cbc311ec1e3d2ce1813a
--- /dev/null
+++ b/pkg/barback/lib/src/node_streams.dart
@@ -0,0 +1,49 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library barback.node_streams;
+
+import 'dart:async';
+
+import 'asset_node.dart';
+import 'log.dart';
+import 'stream_pool.dart';
+
+/// A collection of streams that are common to nodes in barback's package graph.
+class NodeStreams {
+ /// A stream that emits an event whenever the node is no longer dirty.
+ ///
+ /// This is synchronous in order to guarantee that it will emit an event as
+ /// soon as [isDirty] flips from `true` to `false`.
+ Stream get onDone => onDoneController.stream;
+ final onDoneController = new StreamController.broadcast(sync: true);
+
+ /// A stream that emits any new assets produced by the node.
+ ///
+ /// Assets are emitted synchronously to ensure that any changes are thoroughly
+ /// propagated as soon as they occur.
+ Stream<AssetNode> get onAsset => onAssetPool.stream;
+ final onAssetPool = new StreamPool<AssetNode>.broadcast();
+ final onAssetController =
+ new StreamController<AssetNode>.broadcast(sync: true);
+
+ /// A stream that emits an event whenever any the node logs an entry.
+ Stream<LogEntry> get onLog => onLogPool.stream;
+ final onLogPool = new StreamPool<LogEntry>.broadcast();
+ final onLogController = new StreamController<LogEntry>.broadcast(sync: true);
+
+ NodeStreams() {
+ onAssetPool.add(onAssetController.stream);
+ onLogPool.add(onLogController.stream);
+ }
+
+ /// Closes all the streams.
+ void close() {
+ onDoneController.close();
+ onAssetController.close();
+ onAssetPool.close();
+ onLogController.close();
+ onLogPool.close();
+ }
+}
« no previous file with comments | « pkg/barback/lib/src/group_runner.dart ('k') | pkg/barback/lib/src/phase.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698