Index: lib/src/asset/dart/serialize.dart |
diff --git a/lib/src/asset/dart/serialize.dart b/lib/src/asset/dart/serialize.dart |
index f95022d65f38c28e3e380621eb297bfa88721fe7..7af294171080c45bf04820e8a4dd77d20e0e3000 100644 |
--- a/lib/src/asset/dart/serialize.dart |
+++ b/lib/src/asset/dart/serialize.dart |
@@ -5,6 +5,7 @@ |
import 'dart:async'; |
import 'dart:isolate'; |
+import 'package:async/async.dart'; |
import 'package:barback/barback.dart'; |
//# if source_span |
@@ -12,7 +13,6 @@ import 'package:source_span/source_span.dart'; |
//# end |
import 'serialize/exception.dart'; |
-import 'utils.dart'; |
export 'serialize/aggregate_transform.dart'; |
export 'serialize/exception.dart'; |
@@ -77,7 +77,7 @@ SourceLocation deserializeLocation(Map location) { |
/// Converts [stream] into a serializable map. |
/// |
/// [serializeEvent] is used to serialize each event from the stream. |
-Map serializeStream(Stream stream, serializeEvent(event)) { |
+Map serializeStream/*<T>*/(Stream/*<T>*/ stream, serializeEvent(/*=T*/ event)) { |
var receivePort = new ReceivePort(); |
var map = {'replyTo': receivePort.sendPort}; |
@@ -102,8 +102,9 @@ Map serializeStream(Stream stream, serializeEvent(event)) { |
/// Converts a serializable map into a [Stream]. |
/// |
/// [deserializeEvent] is used to deserialize each event from the stream. |
-Stream deserializeStream(Map stream, deserializeEvent(event)) { |
- return callbackStream(() { |
+Stream/*<T>*/ deserializeStream/*<T>*/(Map stream, |
+ /*=T*/ deserializeEvent(event)) { |
+ return new LazyStream(() { |
var receivePort = new ReceivePort(); |
stream['replyTo'].send({'replyTo': receivePort.sendPort}); |
@@ -133,15 +134,18 @@ Stream deserializeStream(Map stream, deserializeEvent(event)) { |
/// |
/// The returned Future will complete to the value or error returned by |
/// [respond]. |
-Future call(SendPort port, message) { |
+Future/*<T>*/ call/*<T>*/(SendPort port, message) { |
var receivePort = new ReceivePort(); |
port.send({ |
'message': message, |
'replyTo': receivePort.sendPort |
}); |
- return receivePort.first.then((response) { |
- if (response['type'] == 'success') return response['value']; |
+ return new Future.sync(() async { |
+ var response = await receivePort.first; |
+ if (response['type'] == 'success') { |
+ return response['value'] as dynamic/*=T*/; |
+ } |
assert(response['type'] == 'error'); |
var exception = deserializeException(response['error']); |
return new Future.error(exception, exception.stackTrace); |