beamtea_stopwatch (beamtea v0.1.2)

View Source

A bubble: a count-up stopwatch, mirroring the stopwatch package in charmbracelet/bubbles.

Self-ticking like beamtea_timer. Start it, forward messages to update/2, and read elapsed_ms/1.

Summary

Functions

Equivalent to new(#{}).

Options: interval_ms (tick granularity, default 100).

Reset the elapsed time to zero (keeps running state).

Start (or resume); returns the command scheduling the first tick.

Pause/resume.

Advance on its own tick; ignore other messages.

Render elapsed time as MM:SS.CS.

Types

model/0

-opaque model()

Functions

elapsed_ms(_)

-spec elapsed_ms(model()) -> non_neg_integer().

new()

-spec new() -> model().

Equivalent to new(#{}).

new(Opts)

-spec new(map()) -> model().

Options: interval_ms (tick granularity, default 100).

reset(M)

-spec reset(model()) -> model().

Reset the elapsed time to zero (keeps running state).

running(_)

-spec running(model()) -> boolean().

start(_)

-spec start(model()) -> beamtea:cmd().

Start (or resume); returns the command scheduling the first tick.

toggle(M)

-spec toggle(model()) -> {model(), beamtea:cmd()}.

Pause/resume.

update(Msg, M)

-spec update(term(), model()) -> {model(), beamtea:cmd()}.

Advance on its own tick; ignore other messages.

view(_)

-spec view(model()) -> iodata().

Render elapsed time as MM:SS.CS.