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

Side by Side Diff: lib/src/result/release_sink.dart

Issue 2996143002: Add methods to Result. Bump version to 2.0 and remove deprecated features. (Closed)
Patch Set: Address comments, run dartfmt on tests too. Created 3 years, 3 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
« no previous file with comments | « lib/src/result/future.dart ('k') | lib/src/result/release_transformer.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import '../result.dart'; 7 import 'result.dart';
8 8
9 /// Use [Result.captureSinkTransformer]. 9 /// Used by [Result.releaseSink].
10 @Deprecated("Will be removed in async 2.0.0.")
11 class ReleaseSink<T> implements EventSink<Result<T>> { 10 class ReleaseSink<T> implements EventSink<Result<T>> {
12 final EventSink _sink; 11 final EventSink _sink;
13 12
14 ReleaseSink(EventSink<T> sink) : _sink = sink; 13 ReleaseSink(EventSink<T> sink) : _sink = sink;
15 14
16 void add(Result<T> result) { 15 void add(Result<T> result) {
17 if (result.isValue) { 16 result.addTo(_sink);
18 _sink.add(result.asValue.value);
19 } else {
20 var error = result.asError;
21 _sink.addError(error.error, error.stackTrace);
22 }
23 } 17 }
24 18
25 void addError(Object error, [StackTrace stackTrace]) { 19 void addError(Object error, [StackTrace stackTrace]) {
26 // Errors may be added by intermediate processing, even if it is never 20 // Errors may be added by intermediate processing, even if it is never
27 // added by CaptureSink. 21 // added by CaptureSink.
28 _sink.addError(error, stackTrace); 22 _sink.addError(error, stackTrace);
29 } 23 }
30 24
31 void close() { 25 void close() {
32 _sink.close(); 26 _sink.close();
33 } 27 }
34 } 28 }
OLDNEW
« no previous file with comments | « lib/src/result/future.dart ('k') | lib/src/result/release_transformer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698