OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 import 'dart:async'; | |
6 | |
7 import '../result.dart'; | |
8 | |
9 /// Use [Result.captureSinkTransformer]. | |
10 @Deprecated("Will be removed in async 2.0.0.") | |
11 class ReleaseSink<T> implements EventSink<Result<T>> { | |
12 final EventSink _sink; | |
13 | |
14 ReleaseSink(EventSink<T> sink) : _sink = sink; | |
15 | |
16 void add(Result<T> result) { | |
17 if (result.isValue) { | |
18 _sink.add(result.asValue.value); | |
19 } else { | |
20 var error = result.asError; | |
21 _sink.addError(error.error, error.stackTrace); | |
22 } | |
23 } | |
24 | |
25 void addError(Object error, [StackTrace stackTrace]) { | |
26 // Errors may be added by intermediate processing, even if it is never | |
27 // added by CaptureSink. | |
28 _sink.addError(error, stackTrace); | |
29 } | |
30 | |
31 void close() { | |
32 _sink.close(); | |
33 } | |
34 } | |
OLD | NEW |