findObservableInScope method

Observable? findObservableInScope(
  1. Observable? target,
  2. String? scopeId,
  3. String? observableKey
)

Implementation

Observable? findObservableInScope(
    Observable? target, String? scopeId, String? observableKey) {
  // Find Scope
  Scope? scope =
      directory.containsKey(scopeId) ? directory[scopeId]!.last : null;

  // Find Observable in Scope
  Observable? observable;
  if (scope != null) {
    observable = scope.observables.containsKey(observableKey)
        ? scope.observables[observableKey]
        : null;
  }

  // Not Found
  if ((observable == null) && (target != null) && (target.scope != null)) {
    // Create New Unresolved
    unresolved ??= HashMap<String?, List<Observable>>();

    // Create New Unresolved Scope
    if (!unresolved!.containsKey(scopeId)) unresolved![scopeId] = [];

    // Create New Unresolved Scope Target
    if (!unresolved![scopeId]!.contains(target)) {
      unresolved![scopeId]!.add(target);
    }
  }

  return observable;
}