| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 library barback.node_streams; |
| 6 |
| 7 import 'dart:async'; |
| 8 |
| 9 import 'asset_node.dart'; |
| 10 import 'log.dart'; |
| 11 import 'stream_pool.dart'; |
| 12 |
| 13 /// A collection of streams that are common to nodes in barback's package graph. |
| 14 class NodeStreams { |
| 15 /// A stream that emits an event whenever the node is no longer dirty. |
| 16 /// |
| 17 /// This is synchronous in order to guarantee that it will emit an event as |
| 18 /// soon as [isDirty] flips from `true` to `false`. |
| 19 Stream get onDone => onDoneController.stream; |
| 20 final onDoneController = new StreamController.broadcast(sync: true); |
| 21 |
| 22 /// A stream that emits any new assets produced by the node. |
| 23 /// |
| 24 /// Assets are emitted synchronously to ensure that any changes are thoroughly |
| 25 /// propagated as soon as they occur. |
| 26 Stream<AssetNode> get onAsset => onAssetPool.stream; |
| 27 final onAssetPool = new StreamPool<AssetNode>.broadcast(); |
| 28 final onAssetController = |
| 29 new StreamController<AssetNode>.broadcast(sync: true); |
| 30 |
| 31 /// A stream that emits an event whenever any the node logs an entry. |
| 32 Stream<LogEntry> get onLog => onLogPool.stream; |
| 33 final onLogPool = new StreamPool<LogEntry>.broadcast(); |
| 34 final onLogController = new StreamController<LogEntry>.broadcast(sync: true); |
| 35 |
| 36 NodeStreams() { |
| 37 onAssetPool.add(onAssetController.stream); |
| 38 onLogPool.add(onLogController.stream); |
| 39 } |
| 40 |
| 41 /// Closes all the streams. |
| 42 void close() { |
| 43 onDoneController.close(); |
| 44 onAssetController.close(); |
| 45 onAssetPool.close(); |
| 46 onLogController.close(); |
| 47 onLogPool.close(); |
| 48 } |
| 49 } |
| OLD | NEW |