watchForConfigChanges method
the watcher for the BrickOvenYaml.file
Implementation
Future<bool> watchForConfigChanges(
String path, {
FutureOr<void> Function()? onChange,
}) async {
final watchCompleter = Completer<bool>();
assert(!_completers.containsKey(path), 'Already watching $path');
final yamlListener = watcher(path).events.listen((event) async {
await onChange?.call();
await _cancelWatcher(path, shouldQuit: false);
});
await _cancelWatcher(path, shouldQuit: false);
_completers[path] = watchCompleter;
final shouldQuit = await watchCompleter.future;
await yamlListener.cancel();
return shouldQuit;
}