Angular Signal Generators
    Preparing search index...
    • Creates a signal that acts either a timer or interval. Emitting increasing numbers for each iteration, starting with an initial 0. Using a ReactiveSource as a parameter will cause the timer to immediately emit if it is reduced to an amount that would move due time into the past.

      Parameters

      • timerTime: ValueSource<number>

        A constant or ReactiveSource that emits how long until the timer is due.

      • OptionalintervalTime: null | ValueSource<number>

        An optional constant or ReactiveSource that emits how long until the timer is due after the initial time was emitted.

      • Optionaloptions: TimerSignalOptions

        An optional object that affects behavior of the signal.

      Returns TimerSignal

      const dueInASecond = timerSignal(1000);
      const dueEverySecond = timerSignal(1000, 1000);
      const dueTime = computed(() => 500 + dueEverySecond() * 50);
      const adjustableDueTime = timerSignal(dueTime, dueTime);

      effect(() => console.log('due in a second', dueInASecond()));
      effect(() => console.log('due every second', dueEverySecond()));
      effect(() => console.log('due every second', adjustableDueTime()));