Macaw.Data.Clock behaviour (macaw_data v0.21.1)
View SourceThe runtime's clock, a behavior over an argument (spec/01 §6.5), so a test's clock holds its state without a global. Moved from macaw_live with the source managers, which read it (dco-tek/macaw/macaw#478 decision 6a, #450, #460).
The runtime reads the clock in one place, the page, once per pulse (spec/01 §6.2).
That instant is the surface's now: every request's now, every cell's context now and
every event's time. A source manager reads it once for the reads of a burst. No
source, component, cell or turn reads a clock.
A clock is given as {module, arg}: {Macaw.Data.Clock.System, nil}, the default, or
{Macaw.Data.Clock.Manual, clock} in a test.
Summary
Callbacks
Cancels a timer send_after/4 armed; :ok whether or not it had fired.
Monotonic milliseconds, for debounces, ticks, backoffs and timeouts.
The wall time, UTC.
Sends message to pid after ms milliseconds; the timer's reference.
Functions
A timer canceled.
Whether a value is a clock: {module, arg} of a loaded module exporting the four
callbacks. A clock: that isn't one is {[:clock], {:type, :clock}}.
The clock's monotonic milliseconds.
The clock's wall time.
A timer on the clock: message sent to pid after ms.
Types
Callbacks
Cancels a timer send_after/4 armed; :ok whether or not it had fired.
Monotonic milliseconds, for debounces, ticks, backoffs and timeouts.
@callback now(arg :: term()) :: DateTime.t()
The wall time, UTC.
@callback send_after(arg :: term(), pid(), message :: term(), ms :: non_neg_integer()) :: reference()
Sends message to pid after ms milliseconds; the timer's reference.
Functions
A timer canceled.
Whether a value is a clock: {module, arg} of a loaded module exporting the four
callbacks. A clock: that isn't one is {[:clock], {:type, :clock}}.
The clock's monotonic milliseconds.
@spec now(t()) :: DateTime.t()
The clock's wall time.
@spec send_after(t(), pid(), term(), non_neg_integer()) :: reference()
A timer on the clock: message sent to pid after ms.