Angular Signal Generators
    Preparing search index...
    • An effect that will start, stop, or conditionally run based on conditions set in the GatedEffectOptions. This is most effective for stopping an effect as it will properly clean up after itself and not track signals unnecessarily.

      Parameters

      • effectFn: (onCleanup: EffectCleanupRegisterFn) => void

        The function to be executed whenever all gate conditions are met.

      • options: GatedEffectOptions = {}

        Standard effect options, plus gate conditions filter (condition that prevents running), start (start running effect), times (number of times to execute), and until (stop running effect)

      Returns EffectRef

      const $userInfo = signal<UserInfo | undefined>(undefined);
      gatedEffect(() => doSomethingWithRequiredUserInfo($userInfo()!), { start: () => $userInfo() !== undefined, times: 1 });