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

Side by Side Diff: pkg/barback/lib/src/utils.dart

Issue 55983005: Serialize barback assets more efficiently. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 7 years, 1 month 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
« no previous file with comments | « pkg/barback/lib/src/serialize.dart ('k') | pkg/barback/test/asset_test.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) 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 library barback.utils; 5 library barback.utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 /// A pair of values. 9 /// A pair of values.
10 class Pair<E, F> { 10 class Pair<E, F> {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 stream.listen( 189 stream.listen(
190 controller.add, 190 controller.add,
191 onError: controller.addError, 191 onError: controller.addError,
192 onDone: controller.close); 192 onDone: controller.close);
193 }).catchError((e, stackTrace) { 193 }).catchError((e, stackTrace) {
194 controller.addError(e, stackTrace); 194 controller.addError(e, stackTrace);
195 controller.close(); 195 controller.close();
196 }); 196 });
197 return controller.stream; 197 return controller.stream;
198 } 198 }
199
200 /// Returns a [Stream] that will emit the same values as the stream returned by
201 /// [callback].
202 ///
203 /// [callback] will only be called when the returned [Stream] gets a subscriber.
204 Stream callbackStream(Stream callback()) {
205 var subscription;
206 var controller;
207 controller = new StreamController(onListen: () {
208 subscription = callback().listen(controller.add,
209 onError: controller.addError,
210 onDone: controller.close);
211 },
212 onCancel: () => subscription.cancel(),
213 onPause: () => subscription.pause(),
214 onResume: () => subscription.resume(),
215 sync: true);
216 return controller.stream;
217 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/serialize.dart ('k') | pkg/barback/test/asset_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698