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

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

Issue 2475303002: Revert "Handle the case of Stream.take(0) better." This reverts commit 8cead4090cc0b1184a2ad552003a… (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | sdk/lib/async/stream_pipe.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 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
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 * that the future will complete with the first error on the stream and then 896 * that the future will complete with the first error on the stream and then
897 * cancel the subscription. 897 * cancel the subscription.
898 * 898 *
899 * In case of a `done` event the future completes with the given 899 * In case of a `done` event the future completes with the given
900 * [futureValue]. 900 * [futureValue].
901 */ 901 */
902 Future/*<E>*/ drain/*<E>*/([/*=E*/ futureValue]) 902 Future/*<E>*/ drain/*<E>*/([/*=E*/ futureValue])
903 => listen(null, cancelOnError: true).asFuture/*<E>*/(futureValue); 903 => listen(null, cancelOnError: true).asFuture/*<E>*/(futureValue);
904 904
905 /** 905 /**
906 * Provides at most the first [count] data events of this stream. 906 * Provides at most the first [n] values of this stream.
907 * 907 *
908 * Forwards all events of this stream to the returned stream 908 * Forwards the first [n] data events of this stream, and all error
909 * until [count] data events have been forwarded or this stream ends, 909 * events, to the returned stream, and ends with a done event.
910 * then ends the returned stream with a done event.
911 * 910 *
912 * If this stream produces fewer than [count] data events before it's done, 911 * If this stream produces fewer than [count] values before it's done,
913 * so will the returned stream. 912 * so will the returned stream.
914 * 913 *
915 * Starts listening to this stream when the returned stream is listened to 914 * Stops listening to the stream after the first [n] elements have been
916 * and stops listening when the first [count] data events have been received. 915 * received.
917 * 916 *
918 * This means that if this is a single-subscription (non-broadcast) streams 917 * Internally the method cancels its subscription after these elements. This
919 * it cannot be reused after the returned stream has been listened to. 918 * means that single-subscription (non-broadcast) streams are closed and
919 * cannot be reused after a call to this method.
920 * 920 *
921 * If this is a broadcast stream, the returned stream is a broadcast stream. 921 * The returned stream is a broadcast stream if this stream is.
922 * In that case, the events are only counted from the time 922 * For a broadcast stream, the events are only counted from the time
923 * the returned stream is listened to. 923 * the returned stream is listened to.
924 */ 924 */
925 Stream<T> take(int count) { 925 Stream<T> take(int count) {
926 return new _TakeStream<T>(this, count); 926 return new _TakeStream<T>(this, count);
927 } 927 }
928 928
929 /** 929 /**
930 * Forwards data events while [test] is successful. 930 * Forwards data events while [test] is successful.
931 * 931 *
932 * The returned stream provides the same events as this stream as long 932 * The returned stream provides the same events as this stream as long
933 * as [test] returns `true` for the event data. The stream is done 933 * as [test] returns [:true:] for the event data. The stream is done
934 * when either this stream is done, or when this stream first provides 934 * when either this stream is done, or when this stream first provides
935 * a value that [test] doesn't accept. 935 * a value that [test] doesn't accept.
936 * 936 *
937 * Stops listening to the stream after the accepted elements. 937 * Stops listening to the stream after the accepted elements.
938 * 938 *
939 * Internally the method cancels its subscription after these elements. This 939 * Internally the method cancels its subscription after these elements. This
940 * means that single-subscription (non-broadcast) streams are closed and 940 * means that single-subscription (non-broadcast) streams are closed and
941 * cannot be reused after a call to this method. 941 * cannot be reused after a call to this method.
942 * 942 *
943 * The returned stream is a broadcast stream if this stream is. 943 * The returned stream is a broadcast stream if this stream is.
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 class _ControllerEventSinkWrapper<T> implements EventSink<T> { 1827 class _ControllerEventSinkWrapper<T> implements EventSink<T> {
1828 EventSink _sink; 1828 EventSink _sink;
1829 _ControllerEventSinkWrapper(this._sink); 1829 _ControllerEventSinkWrapper(this._sink);
1830 1830
1831 void add(T data) { _sink.add(data); } 1831 void add(T data) { _sink.add(data); }
1832 void addError(error, [StackTrace stackTrace]) { 1832 void addError(error, [StackTrace stackTrace]) {
1833 _sink.addError(error, stackTrace); 1833 _sink.addError(error, stackTrace);
1834 } 1834 }
1835 void close() { _sink.close(); } 1835 void close() { _sink.close(); }
1836 } 1836 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/async/stream_pipe.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698