alexeyinkin commented on code in PR #24865:
URL: https://github.com/apache/beam/pull/24865#discussion_r1063214480
##########
playground/frontend/playground_components/lib/src/controllers/snippet_editing_controller.dart:
##########
@@ -156,19 +85,32 @@ class SnippetEditingController extends ChangeNotifier {
bool get isChanged => _isChanged;
void _updateIsChanged() {
- _isChanged = _isCodeChanged() || _arePipelineOptionsChanged();
+ _isChanged = _calculateIsChanged();
}
- bool _isCodeChanged() {
- return _selectedExample?.source != codeController.fullText;
+ bool _calculateIsChanged() {
+ for (final controller in fileControllers) {
+ if (controller.isChanged) {
+ return true;
+ }
+ }
+
+ if (_arePipelineOptionsChanged()) {
+ return true;
+ }
+
+ return false;
}
bool _arePipelineOptionsChanged() {
return _pipelineOptions != (_selectedExample?.pipelineOptions ?? '');
}
void reset() {
- codeController.text = _selectedExample?.source ?? '';
+ for (final controller in fileControllers) {
Review Comment:
`forEach` is only worthy with a tear off like:
```dart
void process(obj) { ... }
collection.forEach(process);
```
Otherwise it is not much shorter than an ordinary `for` but:
- Requires a lambda like `(e) => e.method()` to be constructed which may be
less performant.
- Adds two extra stack frames which is harder to debug.
--
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]