Skip to content

Commit

Permalink
Add type Event ot postEvent
Browse files Browse the repository at this point in the history
IntelliJ expects a "type" field for events; otherwise the JSON will not be parsed correctly. This came up as part of making the widget rebuild table in DevTools clickable (flutter/devtools#4564)

I'm not totally sure this is the change I need, as I don't know how to test this out end-to-end (build Dart SDK and put into Flutter SDK, then run an app with these changes in DDS?). I think it's right because I'm modifying a spot that was first added in https://dart-review.googlesource.com/c/sdk/+/304981, which added `postEvent` in dds_service_extension.

Change-Id: I9a78903dca7855896b6a9b9c3f9e1d62dcb7099e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368202
Reviewed-by: Dan Chevalier <danchevalier@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
  • Loading branch information
helin24 authored and Commit Queue committed May 29, 2024
1 parent 9ee7bb5 commit 7098884
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/dds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 4.2.4
- Added missing type to `Event` in `postEvent`.

# 4.2.3
- Added missing await of `WebSocketChannel.ready` in `startDartDevelopmentService`.

Expand Down
1 change: 1 addition & 0 deletions pkg/dds/lib/src/stream_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ class StreamManager {
streamNotify(stream, <String, dynamic>{
'streamId': stream,
'event': {
'type': 'Event',
'kind': 'Extension',
'timestamp': DateTime.now().millisecondsSinceEpoch,
'extensionData': eventData,
Expand Down
2 changes: 1 addition & 1 deletion pkg/dds/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: dds
version: 4.2.3
version: 4.2.4
description: >-
A library used to spawn the Dart Developer Service, used to communicate with
a Dart VM Service instance.
Expand Down
3 changes: 3 additions & 0 deletions pkg/dds/test/client_post_event_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,18 @@ void main() {
// Test when the stream exists that the event is propagated.
final completer = Completer<void>();
ExtensionData? eventExtensionData;
Event? finalEvent;

service.onEvent('testStream').listen((event) {
finalEvent = event;
eventExtensionData = event.extensionData;
completer.complete();
});
await service.streamListen('testStream');
await service.postEvent('testStream', 'testKind', originalExtensionData);

await completer.future;
expect(finalEvent?.type, equals('Event'));
expect(eventExtensionData?.data, equals(originalExtensionData));
});
}

0 comments on commit 7098884

Please sign in to comment.