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

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

Issue 14246008: Allow Object when doing lookups. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix type error. Created 7 years, 6 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) 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 result._setError(e); 300 result._setError(e);
301 }, 301 },
302 onDone: () { 302 onDone: () {
303 result._setValue(value); 303 result._setValue(value);
304 }, 304 },
305 cancelOnError: true); 305 cancelOnError: true);
306 return result; 306 return result;
307 } 307 }
308 308
309 /** 309 /**
310 * Checks whether [match] occurs in the elements provided by this stream. 310 * Checks whether [needle] occurs in the elements provided by this stream.
311 * 311 *
312 * Completes the [Future] when the answer is known. 312 * Completes the [Future] when the answer is known.
313 * If this stream reports an error, the [Future] will report that error. 313 * If this stream reports an error, the [Future] will report that error.
314 */ 314 */
315 Future<bool> contains(T match) { 315 Future<bool> contains(Object needle) {
316 _FutureImpl<bool> future = new _FutureImpl<bool>(); 316 _FutureImpl<bool> future = new _FutureImpl<bool>();
317 StreamSubscription subscription; 317 StreamSubscription subscription;
318 subscription = this.listen( 318 subscription = this.listen(
319 // TODO(ahe): Restore type when feature is implemented in dart2js 319 // TODO(ahe): Restore type when feature is implemented in dart2js
320 // checked mode. http://dartbug.com/7733 320 // checked mode. http://dartbug.com/7733
321 (/*T*/ element) { 321 (/*T*/ element) {
322 _runUserCode( 322 _runUserCode(
323 () => (element == match), 323 () => (element == needle),
324 (bool isMatch) { 324 (bool isMatch) {
325 if (isMatch) { 325 if (isMatch) {
326 subscription.cancel(); 326 subscription.cancel();
327 future._setValue(true); 327 future._setValue(true);
328 } 328 }
329 }, 329 },
330 _cancelAndError(subscription, future) 330 _cancelAndError(subscription, future)
331 ); 331 );
332 }, 332 },
333 onError: future._setError, 333 onError: future._setError,
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 * 1241 *
1242 * If a [moveNext] call has been made, it will complete with `false` as value, 1242 * If a [moveNext] call has been made, it will complete with `false` as value,
1243 * as will all further calls to [moveNext]. 1243 * as will all further calls to [moveNext].
1244 * 1244 *
1245 * If you need to stop listening for values before the stream iterator is 1245 * If you need to stop listening for values before the stream iterator is
1246 * automatically closed, you must call [cancel] to ensure that the stream 1246 * automatically closed, you must call [cancel] to ensure that the stream
1247 * is properly closed. 1247 * is properly closed.
1248 */ 1248 */
1249 void cancel(); 1249 void cancel();
1250 } 1250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698