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

Side by Side Diff: lib/src/json_document_transformer.dart

Issue 2041983003: Add StreamChannel.withCloseGuarantee. (Closed) Base URL: git@github.com:dart-lang/stream_channel.git@master
Patch Set: Code review changes Created 4 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
« no previous file with comments | « lib/src/close_guarantee_channel.dart ('k') | lib/src/stream_channel_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:convert'; 5 import 'dart:convert';
6 6
7 import 'package:async/async.dart'; 7 import 'package:async/async.dart';
8 8
9 import '../stream_channel.dart'; 9 import '../stream_channel.dart';
10 import 'stream_channel_transformer.dart'; 10 import 'stream_channel_transformer.dart';
(...skipping 22 matching lines...) Expand all
33 JsonDocumentTransformer({reviver(key, value), toEncodable(object)}) 33 JsonDocumentTransformer({reviver(key, value), toEncodable(object)})
34 : _codec = new JsonCodec(reviver: reviver, toEncodable: toEncodable); 34 : _codec = new JsonCodec(reviver: reviver, toEncodable: toEncodable);
35 35
36 JsonDocumentTransformer._(this._codec); 36 JsonDocumentTransformer._(this._codec);
37 37
38 StreamChannel bind(StreamChannel<String> channel) { 38 StreamChannel bind(StreamChannel<String> channel) {
39 var stream = channel.stream.map(_codec.decode); 39 var stream = channel.stream.map(_codec.decode);
40 var sink = new StreamSinkTransformer.fromHandlers(handleData: (data, sink) { 40 var sink = new StreamSinkTransformer.fromHandlers(handleData: (data, sink) {
41 sink.add(_codec.encode(data)); 41 sink.add(_codec.encode(data));
42 }).bind(channel.sink); 42 }).bind(channel.sink);
43 return new StreamChannel(stream, sink); 43 return new StreamChannel.withCloseGuarantee(stream, sink);
44 } 44 }
45 } 45 }
OLDNEW
« no previous file with comments | « lib/src/close_guarantee_channel.dart ('k') | lib/src/stream_channel_transformer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698