Skip to content

Commit a0316fd

Browse files
committed
Make _messages a broadcast stream
1 parent a662c7c commit a0316fd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/graphql/lib/src/links/websocket_link/websocket_client.dart

+7-2
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,13 @@ class GraphQLWebSocketChannel extends StreamChannelMixin<dynamic>
636636
Stream<GraphQLSocketMessage>? _messages;
637637

638638
/// Stream of messages from the endpoint parsed as GraphQLSocketMessages
639-
Stream<GraphQLSocketMessage> get messages => _messages ??=
640-
stream.map<GraphQLSocketMessage>(GraphQLSocketMessage.parse);
639+
Stream<GraphQLSocketMessage> get messages {
640+
if (_messages == null) _messages = stream.map((event) {
641+
return GraphQLSocketMessage.parse(event);
642+
}).asBroadcastStream();
643+
644+
return _messages!;
645+
}
641646

642647
String? get protocol => _webSocket.protocol;
643648

0 commit comments

Comments
 (0)