You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/11/24 04:46:19 UTC
[GitHub] [beam] Malarg commented on a diff in pull request #24338: Show error messages when Playground requests fail (#24033)
Malarg commented on code in PR #24338:
URL: https://github.com/apache/beam/pull/24338#discussion_r1031052205
##########
playground/frontend/lib/modules/editor/components/share_dropdown/share_tabs/snippet_save_and_share_tabs.dart:
##########
@@ -16,32 +16,59 @@
* limitations under the License.
*/
+import 'dart:async';
+
import 'package:flutter/material.dart';
import 'package:playground/modules/editor/components/share_dropdown/share_tabs/example_share_tabs.dart';
import 'package:playground_components/playground_components.dart';
-class SnippetSaveAndShareTabs extends StatelessWidget {
+class SnippetSaveAndShareTabs extends StatefulWidget {
+ final VoidCallback onError;
final PlaygroundController playgroundController;
final TabController tabController;
const SnippetSaveAndShareTabs({
super.key,
+ required this.onError,
required this.playgroundController,
required this.tabController,
});
+ @override
+ State<SnippetSaveAndShareTabs> createState() => _SnippetSaveAndShareTabsState();
+}
+
+class _SnippetSaveAndShareTabsState extends State<SnippetSaveAndShareTabs> {
+ Future<String>? _future;
+
+ @override
+ void initState() {
+ super.initState();
+ unawaited(_initSaving());
+ }
+
+ Future<void> _initSaving() async {
+ try {
Review Comment:
I think that this logic should not be placed in a widget, because:
1. It breaks expectations on widget using. It will be surprise for users of this widget, that it makes request on creation.
2. This approach complicates potential testing.
3. It may reduce performance. What if the user closes popup while requests is running and open it again then?
I suggest to move this logic to playground controller. Run it and subscribe on it result here
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org