open static method
Loads root, then starts recursive native observation after success.
Implementation
static Future<EagleResult<EagleWatchedLibrary>> open(
Directory root, {
Duration settleDelay = const Duration(milliseconds: 75),
int maxDiagnostics = 100,
}) async {
try {
final source = await NativeEagleSource.open(root);
final result = await EagleLibraryLoader(
source,
maxDiagnostics: maxDiagnostics,
).load();
switch (result) {
case EagleFailure<EagleLibrary>(:final diagnostics):
return EagleResult<EagleWatchedLibrary>.failure(diagnostics);
case EagleSuccess<EagleLibrary>(:final value):
final watched = EagleWatchedLibrary._(
source: source,
initial: value,
settleDelay: settleDelay,
);
watched._start();
return EagleResult<EagleWatchedLibrary>.success(watched);
}
} catch (error) {
return EagleResult<EagleWatchedLibrary>.failure(<EagleDiagnostic>[
_watchDiagnostic('watch-open-failed', error),
]);
}
}