From 3a0aabc37b9681b643cdbad095c1d921b31c120b Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Wed, 18 Apr 2018 09:24:52 -0700 Subject: [PATCH] Add docs to VMService.onEvent() (#16711) --- packages/flutter_tools/lib/src/vmservice.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart index f78e4663b6..25420c3836 100644 --- a/packages/flutter_tools/lib/src/vmservice.dart +++ b/packages/flutter_tools/lib/src/vmservice.dart @@ -182,7 +182,14 @@ class VMService { Future> get onTimelineEvent => onEvent('Timeline'); // TODO(johnmccutchan): Add FlutterView events. - // Listen for a specific event name. + /// Returns a stream of VM service events. + /// + /// This purposely returns a `Future>` rather than a `Stream` + /// because it first registers with the VM to receive events on the stream, + /// and only once the VM has acknowledged that the stream has started will + /// we return the associated stream. Any attempt to streamline this API into + /// returning `Stream` should take that into account to avoid race + /// conditions. Future> onEvent(String streamId) async { await _streamListen(streamId); return _getEventController(streamId).stream;