Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6b290ad

Browse files
committed
Apply Yegor's idea
1 parent b72ea9e commit 6b290ad

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

lib/web_ui/dev/build.dart

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BuildCommand extends Command<bool> {
2727
String get name => 'build';
2828

2929
@override
30-
String get description => 'Build the web engine package.';
30+
String get description => 'Build the Flutter web engine.';
3131

3232
bool get isWatchMode => argResults['watch'];
3333

@@ -141,18 +141,16 @@ class PipelineWatcher {
141141
}
142142

143143
int _pipelineRunCount = 0;
144-
bool _pipelineScheduled = false;
144+
Timer _scheduledPipeline;
145145

146146
void _onEvent(WatchEvent event) {
147147
final String relativePath = path.relative(event.path, from: dir);
148148
print('- [${event.type}] ${relativePath}');
149-
if (_pipelineScheduled) {
150-
return;
151-
}
149+
152150
_pipelineRunCount++;
153-
_pipelineScheduled = true;
154-
Future.delayed(const Duration(milliseconds: 100)).then((_) {
155-
_pipelineScheduled = false;
151+
_scheduledPipeline?.cancel();
152+
_scheduledPipeline = Timer(const Duration(milliseconds: 100), () {
153+
_scheduledPipeline = null;
156154
_runPipeline();
157155
});
158156
}
@@ -163,11 +161,7 @@ class PipelineWatcher {
163161
case PipelineStatus.started:
164162
pipeline.stop().then((_) {
165163
runCount = _pipelineRunCount;
166-
return pipeline.start();
167-
}).then((_) {
168-
if (runCount == _pipelineRunCount) {
169-
print('*** Done! ***');
170-
}
164+
pipeline.start().then((_) => _pipelineDone(runCount));
171165
});
172166
break;
173167

@@ -177,12 +171,14 @@ class PipelineWatcher {
177171

178172
default:
179173
runCount = _pipelineRunCount;
180-
pipeline.start().then((_) {
181-
if (runCount == _pipelineRunCount) {
182-
print('Done!');
183-
}
184-
});
174+
pipeline.start().then((_) => _pipelineDone(runCount));
185175
break;
186176
}
187177
}
178+
179+
void _pipelineDone(int pipelineRunCount) {
180+
if (pipelineRunCount == _pipelineRunCount) {
181+
print('*** Done! ***');
182+
}
183+
}
188184
}

0 commit comments

Comments
 (0)