| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 event_helper; | 5 library event_helper; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 abstract class Event { | 9 abstract class Event { |
| 10 void replay(EventSink sink); | 10 void replay(EventSink sink); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 Events(); | 67 Events(); |
| 68 | 68 |
| 69 Events.fromIterable(Iterable iterable) { | 69 Events.fromIterable(Iterable iterable) { |
| 70 for (var value in iterable) add(value); | 70 for (var value in iterable) add(value); |
| 71 close(); | 71 close(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 /** Capture events from a stream into a new [Events] object. */ | 74 /** Capture events from a stream into a new [Events] object. */ |
| 75 factory Events.capture(Stream stream, | 75 factory Events.capture(Stream stream, |
| 76 { bool cancelOnError: false }) = CaptureEvents; | 76 { bool cancelOnError }) = CaptureEvents; |
| 77 | 77 |
| 78 // EventSink interface. | 78 // EventSink interface. |
| 79 void add(var value) { | 79 void add(var value) { |
| 80 if (trace) print("Events#$hashCode: add($value)"); | 80 if (trace) print("Events#$hashCode: add($value)"); |
| 81 events.add(new DataEvent(value)); | 81 events.add(new DataEvent(value)); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void addError(error, [StackTrace stackTrace]) { | 84 void addError(error, [StackTrace stackTrace]) { |
| 85 if (trace) print("Events#$hashCode: addError($error)"); | 85 if (trace) print("Events#$hashCode: addError($error)"); |
| 86 events.add(new ErrorEvent(error)); | 86 events.add(new ErrorEvent(error)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 void resume() { | 173 void resume() { |
| 174 if (trace) print("Events#$hashCode: resume"); | 174 if (trace) print("Events#$hashCode: resume"); |
| 175 subscription.resume(); | 175 subscription.resume(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void onDone(void action()) { | 178 void onDone(void action()) { |
| 179 if (trace) print("Events#$hashCode: onDone"); | 179 if (trace) print("Events#$hashCode: onDone"); |
| 180 super.onDone(action); | 180 super.onDone(action); |
| 181 } | 181 } |
| 182 } | 182 } |
| OLD | NEW |