Skip to content

Commit

Permalink
Add code excerpt for stream listen hint and fix markdown highlighting…
Browse files Browse the repository at this point in the history
… (#3432)
  • Loading branch information
parlough authored Jul 28, 2021
1 parent 33ef8db commit 79bed10
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions examples/misc/lib/articles/creating-streams/stream_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ void main() {
// demoPause();
}

void onListenHint() {
var stream = Stream.empty();
void handler(dynamic) {}
StreamSubscription<dynamic> subscription;

// #docregion stream-listen-hint
subscription = stream.listen(handler);
// #enddocregion stream-listen-hint

subscription.cancel();
}

void showBasicUsage() {
// #docregion basic-usage
var counterStream =
Expand Down
3 changes: 2 additions & 1 deletion src/_articles/libraries/creating-streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,9 @@ keep these tips in mind:
before the `subscription` variable
has a valid value.

<?code-excerpt "misc/lib/articles/creating-streams/stream_controller.dart (stream-listen-hint)"?>
```dart
subscription = stream.listen(handler);
subscription = stream.listen(handler);
```

* The `onListen`, `onPause`, `onResume`, and `onCancel`
Expand Down

0 comments on commit 79bed10

Please sign in to comment.