Skip to content

Commit 6d961f0

Browse files
committed
Slightly prettier client example
1 parent 96b4260 commit 6d961f0

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lib/Type/IO/Socket/Async.pod

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,18 @@ And a client that connects to it, and prints out what the server answers:
3535
use v6;
3636
3737
await IO::Socket::Async.connect('localhost',3333).then( -> $p {
38-
if $p.status == Kept {
39-
my $conn = $p.result;
40-
my $p2 = $conn.print('Hello, Perl 6');
41-
my $p3 = Promise.new;
42-
$conn.chars-supply.tap(-> $str { say $str; $p3.keep});
43-
await $p3;
44-
$conn.close;
45-
}
38+
if $p.status {
39+
given $p.result {
40+
.print('Hello, Perl 6');
41+
react {
42+
whenever .chars-supply() -> $v {
43+
$v.say;
44+
done;
45+
}
46+
}
47+
.close;
48+
}
49+
}
4650
});
4751
=end code
4852

0 commit comments

Comments
 (0)