Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: sdk/lib/async/stream_controller.dart

Issue 11886013: Make Stream transformation respect the single/multi subscriber nature of the source. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added missing isSingleSubscription impl. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 part of dart.async; 5 part of dart.async;
6 6
7 // ------------------------------------------------------------------- 7 // -------------------------------------------------------------------
8 // Default implementation of a stream with a controller for adding 8 // Default implementation of a stream with a controller for adding
9 // events to the stream. 9 // events to the stream.
10 // ------------------------------------------------------------------- 10 // -------------------------------------------------------------------
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 /** 49 /**
50 * A controller with a [stream] that supports only one single subscriber. 50 * A controller with a [stream] that supports only one single subscriber.
51 * The controller will buffer all incoming events until the subscriber is 51 * The controller will buffer all incoming events until the subscriber is
52 * registered. 52 * registered.
53 */ 53 */
54 StreamController.singleSubscription() { 54 StreamController.singleSubscription() {
55 _stream = new _SingleControllerStream<T>(onSubscriptionStateChange, 55 _stream = new _SingleControllerStream<T>(onSubscriptionStateChange,
56 onPauseStateChange); 56 onPauseStateChange);
57 } 57 }
58 58
59 bool get isSingleSubscription => _stream.isSingleSubscription;
60
59 StreamSubscription listen(void onData(T data), 61 StreamSubscription listen(void onData(T data),
60 { void onError(AsyncError error), 62 { void onError(AsyncError error),
61 void onDone(), 63 void onDone(),
62 bool unsubscribeOnError}) { 64 bool unsubscribeOnError}) {
63 return _stream.listen(onData, 65 return _stream.listen(onData,
64 onError: onError, 66 onError: onError,
65 onDone: onDone, 67 onDone: onDone,
66 unsubscribeOnError: unsubscribeOnError); 68 unsubscribeOnError: unsubscribeOnError);
67 } 69 }
68 70
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 _SingleControllerStream(this._subscriptionHandler, this._pauseHandler); 165 _SingleControllerStream(this._subscriptionHandler, this._pauseHandler);
164 166
165 void _onSubscriptionStateChange() { 167 void _onSubscriptionStateChange() {
166 _subscriptionHandler(); 168 _subscriptionHandler();
167 } 169 }
168 170
169 void _onPauseStateChange() { 171 void _onPauseStateChange() {
170 _pauseHandler(); 172 _pauseHandler();
171 } 173 }
172 } 174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698