isResolved()

in fusion-react/src/async/prepare.js [21:52]


  isResolved(Component, effectId, effectPromiseThunk) {
    let seenEffectIds = this.seen.get(Component);
    let pendingPromises = this.pending.get(Component);

    // Initialize if not present
    if (!seenEffectIds) {
      seenEffectIds = new Set();
      this.seen.set(Component, seenEffectIds);
    }

    // If seen and not pending, then it has been resolved
    if (
      seenEffectIds.has(effectId) &&
      (!pendingPromises || !pendingPromises.has(effectId))
    ) {
      return true;
    }

    // If not yet seen, need to start promise
    if (!seenEffectIds.has(effectId)) {
      if (!pendingPromises) {
        pendingPromises = new Map();
        this.pending.set(Component, pendingPromises);
      }

      const effectPromise = effectPromiseThunk();
      seenEffectIds.add(effectId);
      pendingPromises.set(effectId, effectPromise);
    }

    return false;
  }