alexeyinkin commented on code in PR #22959: URL: https://github.com/apache/beam/pull/22959#discussion_r958454119
########## playground/frontend/lib/modules/messages/listeners/messages_listener.dart: ########## @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:onmessage/onmessage.dart'; +import 'package:playground/modules/messages/handlers/abstract_message_handler.dart'; +import 'package:playground/modules/messages/parsers/messages_parser.dart'; + +class MessagesListener { + final AbstractMessageHandler handler; + + MessagesListener({ + required this.handler, + }) { + OnMessage.instance.stream.listen(_onWindowMessage); Review Comment: This can be easily done without this package with ```dart import 'dart:html' as html; void main() { html.window.onMessage.listen((html.MessageEvent event) { // Handle. }); // ... } ``` But I like to avoid importing `dart:html` directly because: 1. It can produce linter warnings. 2. It only allows to run tests in the web environment while they potentially can be cross-platform and run faster as native code. 3. Should we ever want to build for anything other than web, it will require migration. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
