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

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

Issue 1777453002: Modernize the package's style. (Closed) Base URL: git@github.com:dart-lang/async.git@master
Patch Set: Created 4 years, 9 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
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698