Skip to main content

use_countdown

Function use_countdown 

Source
pub fn use_countdown(
    on_complete: Option<Callback<()>>,
) -> (Signal<i64>, Signal<TimerState>, CountdownControls)
Expand description

Countdown timer hook.

Returns (remaining_seconds, state, controls).

Uses wall-clock calculation internally for accuracy across tab backgrounding. The timer ticks approximately every 100ms for smooth UI updates.

§Parameters

  • on_complete: Optional callback fired once when the countdown reaches zero.

§Example

let (remaining, state, controls) = use_countdown(None);
controls.start.call(90); // Start a 90-second countdown