Last active
August 29, 2015 14:22
-
-
Save danschultz/5a2eec444352a6374c34 to your computer and use it in GitHub Desktop.
event stream controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'package:frappe/frappe.dart'; | |
class EventStreamController<T> implements StreamController { | |
final StreamController<T> _controller; | |
final EventStream<T> _stream; | |
EventStream<T> get stream => _stream; | |
StreamSink<T> get sink => _controller.sink; | |
bool get isClosed => _controller.isClosed; | |
bool get isPaused => _controller.isPaused; | |
bool get hasListener => _controller.hasListener; | |
Future get done => _controller.done; | |
EventStreamController._(StreamController<T> controller) | |
: _controller = controller, | |
_stream = new EventStream(controller.stream); | |
EventStreamController({bool sync: false}) : this._(new StreamController(sync: sync)); | |
EventStreamController.broadcast({bool sync: false}) : this._(new StreamController.broadcast(sync: sync)); | |
Future close() => _controller.close(); | |
void add(T event) => _controller.add(event); | |
Future addStream(Stream<T> source, {bool cancelOnError: true}) => | |
_controller.addStream(source, cancelOnError: cancelOnError); | |
void addError(Object error, [StackTrace stackTrace]) => | |
_controller.addError(error, stackTrace); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment