open static method

Future<EagleResult<EagleWatchedLibrary>> open(
  1. Directory root, {
  2. Duration settleDelay = const Duration(milliseconds: 75),
  3. int maxDiagnostics = 100,
})

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),
    ]);
  }
}