| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library barback.transform_node; | 5 library barback.transform_node; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'asset.dart'; | 9 import 'asset.dart'; |
| 10 import 'asset_id.dart'; | 10 import 'asset_id.dart'; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 /// A stream that emits an event whenever this transform becomes dirty and | 48 /// A stream that emits an event whenever this transform becomes dirty and |
| 49 /// needs to be re-run. | 49 /// needs to be re-run. |
| 50 /// | 50 /// |
| 51 /// This may emit events when the transform was already dirty or while | 51 /// This may emit events when the transform was already dirty or while |
| 52 /// processing transforms. Events are emitted synchronously to ensure that the | 52 /// processing transforms. Events are emitted synchronously to ensure that the |
| 53 /// dirty state is thoroughly propagated as soon as any assets are changed. | 53 /// dirty state is thoroughly propagated as soon as any assets are changed. |
| 54 Stream get onDirty => _onDirtyController.stream; | 54 Stream get onDirty => _onDirtyController.stream; |
| 55 final _onDirtyController = new StreamController.broadcast(sync: true); | 55 final _onDirtyController = new StreamController.broadcast(sync: true); |
| 56 | 56 |
| 57 /// A stream that emits an event whenever this transform logs an entry. | 57 /// A stream that emits an event whenever this transform logs an entry. |
| 58 /// |
| 59 /// This is synchronous because error logs can cause the transform to fail, so |
| 60 /// we need to ensure that their processing isn't delayed until after the |
| 61 /// transform or build has finished. |
| 58 Stream<LogEntry> get onLog => _onLogController.stream; | 62 Stream<LogEntry> get onLog => _onLogController.stream; |
| 59 final _onLogController = new StreamController<LogEntry>.broadcast(); | 63 final _onLogController = new StreamController<LogEntry>.broadcast(sync: true); |
| 60 | 64 |
| 61 TransformNode(this.phase, this.transformer, this.primary) { | 65 TransformNode(this.phase, this.transformer, this.primary) { |
| 62 _primarySubscription = primary.onStateChange.listen((state) { | 66 _primarySubscription = primary.onStateChange.listen((state) { |
| 63 if (state.isRemoved) { | 67 if (state.isRemoved) { |
| 64 remove(); | 68 remove(); |
| 65 } else { | 69 } else { |
| 66 _dirty(); | 70 _dirty(); |
| 67 } | 71 } |
| 68 }); | 72 }); |
| 69 } | 73 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 } | 211 } |
| 208 | 212 |
| 209 void _log(AssetId asset, LogLevel level, String message, Span span) { | 213 void _log(AssetId asset, LogLevel level, String message, Span span) { |
| 210 // If the log isn't already associated with an asset, use the primary. | 214 // If the log isn't already associated with an asset, use the primary. |
| 211 if (asset == null) asset = primary.id; | 215 if (asset == null) asset = primary.id; |
| 212 var info = new TransformInfo(transformer, primary.id); | 216 var info = new TransformInfo(transformer, primary.id); |
| 213 var entry = new LogEntry(info, asset, level, message, span); | 217 var entry = new LogEntry(info, asset, level, message, span); |
| 214 _onLogController.add(entry); | 218 _onLogController.add(entry); |
| 215 } | 219 } |
| 216 } | 220 } |
| OLD | NEW |