| 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.utils.stream_replayer; | 5 library barback.stream_replayer; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import '../utils.dart'; | 10 import 'utils.dart'; |
| 11 | 11 |
| 12 /// Records the values and errors that are sent through a stream and allows them | 12 /// Records the values and errors that are sent through a stream and allows them |
| 13 /// to be replayed arbitrarily many times. | 13 /// to be replayed arbitrarily many times. |
| 14 /// | 14 /// |
| 15 /// This only listens to the wrapped stream when a replayed stream gets a | 15 /// This only listens to the wrapped stream when a replayed stream gets a |
| 16 /// listener. | 16 /// listener. |
| 17 class StreamReplayer<T> { | 17 class StreamReplayer<T> { |
| 18 /// The wrapped stream. | 18 /// The wrapped stream. |
| 19 final Stream<T> _stream; | 19 final Stream<T> _stream; |
| 20 | 20 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 }, onDone: () { | 75 }, onDone: () { |
| 76 _isClosed = true; | 76 _isClosed = true; |
| 77 for (var controller in _controllers) { | 77 for (var controller in _controllers) { |
| 78 controller.close(); | 78 controller.close(); |
| 79 } | 79 } |
| 80 _controllers.clear(); | 80 _controllers.clear(); |
| 81 }); | 81 }); |
| 82 } | 82 } |
| 83 } | 83 } |
| OLD | NEW |