Skip to content

Instantly share code, notes, and snippets.

@alxhub
Created November 4, 2014 23:26
Show Gist options
  • Save alxhub/4424ad3e4aaa8a257fe7 to your computer and use it in GitHub Desktop.
Save alxhub/4424ad3e4aaa8a257fe7 to your computer and use it in GitHub Desktop.
library main;
import 'dart:async';
void main() {
var zs = new ZoneSpecification(print: onPrint);
var zs2 = new ZoneSpecification(print: onPrint2);
var sc;
sc = new StreamController();
runZoned(() {
print("registering");
sc.stream.listen(print);
}, zoneSpecification: zs);
runZoned(() {
print("sending");
sc.add("receiving");
}, zoneSpecification: zs2);
}
onPrint(Zone self, ZoneDelegate parent, Zone zone, String line) {
parent.print(zone, "[inZone] $line");
}
onPrint2(Zone self, ZoneDelegate parent, Zone zone, String line) {
parent.print(zone, "[inZone2] $line");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment