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

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

Issue 11791045: Added toMultiSubscriber on Stream. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « no previous file | sdk/lib/async/stream_impl.dart » ('j') | sdk/lib/async/stream_impl.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Core Stream types 8 // Core Stream types
9 // ------------------------------------------------------------------- 9 // -------------------------------------------------------------------
10 10
11 abstract class Stream<T> { 11 abstract class Stream<T> {
12 Stream(); 12 Stream();
13 13
14 factory Stream.fromFuture(Future<T> future) { 14 factory Stream.fromFuture(Future<T> future) {
15 var controller = new StreamController<T>(); 15 var controller = new StreamController<T>();
16 future.then((value) { 16 future.then((value) {
17 controller.add(value); 17 controller.add(value);
18 controller.close(); 18 controller.close();
19 }, 19 },
20 onError: (error) { 20 onError: (error) {
21 controller.signalError(error); 21 controller.signalError(error);
22 controller.close(); 22 controller.close();
23 }); 23 });
24 return controller.stream; 24 return controller.stream;
25 } 25 }
26 26
27 /** 27 /**
28 * Returns a multi-subscription stream that produces the same events.
floitsch 2013/01/08 14:06:00 same events as [this].
Lasse Reichstein Nielsen 2013/01/09 15:19:17 Done.
29 *
30 * If this stream is single-subscription, the new multi-subscription
floitsch 2013/01/08 14:06:00 As discussed: we want to be more specific on the b
Lasse Reichstein Nielsen 2013/01/09 15:19:17 Done.
31 * stream gets its data by subscribing to this stream which must not already
32 * have a subscriber, and which can't get another subscriber at a later time.
33 *
34 * If this stream is already multi-subscriber, there is no difference between
35 * this stream and the returned stream. They may even be the same object.
36 */
37 Stream<T> toMultiSubscriber();
floitsch 2013/01/08 14:06:00 asMultiSubscriptionStream()
Lasse Reichstein Nielsen 2013/01/09 15:19:17 Very, very long. Doesn't match new StreamControll
38
39 /**
28 * Stream that outputs events from the [sources] in cyclic order. 40 * Stream that outputs events from the [sources] in cyclic order.
29 * 41 *
30 * The merged streams are paused and resumed in order to ensure the proper 42 * The merged streams are paused and resumed in order to ensure the proper
31 * order of output events. 43 * order of output events.
32 */ 44 */
33 factory Stream.cyclic(Iterable<Stream> sources) { 45 factory Stream.cyclic(Iterable<Stream> sources) {
34 return new CyclicScheduleStream<T>(sources); 46 return new CyclicScheduleStream<T>(sources);
35 } 47 }
36 48
37 /** 49 /**
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 sink.signalError(error); 845 sink.signalError(error);
834 } 846 }
835 847
836 /** 848 /**
837 * Handle an incoming done event. 849 * Handle an incoming done event.
838 */ 850 */
839 void handleDone(StreamSink<T> sink) { 851 void handleDone(StreamSink<T> sink) {
840 sink.close(); 852 sink.close();
841 } 853 }
842 } 854 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/async/stream_impl.dart » ('j') | sdk/lib/async/stream_impl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698