Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Document type Tap
one of the few types we have covered completely, I believe :-)
- Loading branch information
Showing
2 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| =begin pod | ||
| =TITLE class Tap | ||
| =SUBTITLE A subscription to a supply | ||
| class Tap { ... } | ||
| A Tap is a subscription to a L<Supply|/type/Supply>. | ||
| my $s = Supply.new; | ||
| my $tap = $s.tap( | ||
| -> $v { say "the value is $v" }, | ||
| done => { say "Supply is done" }, | ||
| closing => { say "Tap closed" }, | ||
| quit => -> $ex { say "Supply finished with error $ex" }, | ||
| ); | ||
| # later | ||
| $tap.close; | ||
| # or | ||
| $s.close($tap); | ||
| =head1 Methods | ||
| =head2 method emit | ||
| method emit(Tap:D:) returns Callable:D | ||
| Returns the callback that is called for emitted events. | ||
| =head2 method done | ||
| method done(Tap:D:) | ||
| Returns the callback that is called on successfully shutting down a channel, | ||
| if any. | ||
| =head2 method quit | ||
| method quit(Tap:D:) | ||
| Returns the callback that is called on shutting down a channel with error, if | ||
| any. | ||
| =head2 method closing | ||
| method closing(Tap:D:) | ||
| Returns the callback that is called on closing the tap. | ||
| =head2 method supply | ||
| method supply(Tap:D:) | ||
| Returns the supply to which the tap belongs. | ||
| =head2 method close | ||
| method closing(Tap:D:) | ||
| Closes the tap. | ||
| =end pod |