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

Unified Diff: sdk/lib/async/stream.dart

Issue 13548002: Add Iterable.fold (and Stream.fold) which replace `reduce`. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/lib/js_array.dart ('k') | sdk/lib/collection/collections.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/stream.dart
diff --git a/sdk/lib/async/stream.dart b/sdk/lib/async/stream.dart
index 759f9c7474391c0dbc13aadc3c52b158223e0429..38ace6dab4daa9a182908c72b7d38e446710cefc 100644
--- a/sdk/lib/async/stream.dart
+++ b/sdk/lib/async/stream.dart
@@ -249,8 +249,18 @@ abstract class Stream<T> {
return streamTransformer.bind(this);
}
- /** Reduces a sequence of values by repeatedly applying [combine]. */
+ /**
+ * Reduces a sequence of values by repeatedly applying [combine].
+ *
+ * *WARNING UPCOMING API-CHANGE*: This method will be changed so that
+ * it doesn't take an initial value. Use [fold] instead.
+ */
Future reduce(var initialValue, combine(var previous, T element)) {
+ return fold(initialValue, combine);
+ }
+
+ /** Reduces a sequence of values by repeatedly applying [combine]. */
+ Future fold(var initialValue, combine(var previous, T element)) {
_FutureImpl result = new _FutureImpl();
var value = initialValue;
StreamSubscription subscription;
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/lib/js_array.dart ('k') | sdk/lib/collection/collections.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698