class

Phosphor::SpinnerMock

Inherits Phosphor::MockWidget < Reference < Object

An animated spinner, for indicating in-progress work.

Generic and app-agnostic: no knowledge of AppState, Msg, or the application theme. The Widget wrapper resolves theme → Style values and sets them in Props before each render.

Owns no timer: it only advances state.frame_index in response to Cmd::Tick. The consuming screen mounts a TickPort in on_mount; the wrapping Widget translates each TickEvent it receives into a Cmd::Tick for this mock's handle_cmd. See .claude/rules/async.md.

Constructors

new(props : Props = Props.new, state : WidgetState = WidgetState.new)

Initialises the spinner with props and an optional state. Both default, since every Props field has a sensible default of its own.

Source

Instance methods

handle_cmd(cmd : Cmd) : CmdResult

Responds to Cmd::Tick by advancing state.frame_index, wrapping at props.frames.size. A no-op (returns CmdResult::None) if props.frames is empty, to avoid dividing by zero. Any other command also returns CmdResult::None.

Source
props
Source
props=(props : Props)
Source
render_content(frame : Frame, buf : Buffer) : Void

Writes the current spinner frame into buf at frame.x, frame.y.

Does nothing if props.frames is empty — there's no glyph to draw.

Source
state

Narrows the inherited state getter to SpinnerMock::WidgetState. Safe: initialize only ever stores a WidgetState into the base @state ivar.

Source

Nested types