struct

Phosphor::AppState

Inherits Struct < Value < Object

Immutable snapshot of the entire application at one moment in time.

AppState is a Crystal struct — value semantics, stack-allocated, no shared mutable state. Every state change returns a new instance via a with_* copy method; nothing mutates in place. Think of it as a strongly typed params hash that describes the full page at a single frame.

Constructors

new(todos : Array(Todo) = [] of Todo, selected : Int32 = 0)
Source

Instance methods

selected
Source
todos
Source
with_selected(selected : Int32) : AppState

Returns a new AppState with selected replaced, all other fields unchanged.

Source
with_todo_toggled(index : Int32) : AppState

Returns a new AppState with the todo at index toggled.

Rebuilds the array with only the target item replaced — no other todos are touched and the original array is not mutated. index is clamped to 0..todos.size - 1; returns self when todos is empty.

Source
with_todos(todos : Array(Todo)) : AppState

Returns a new AppState with todos replaced, all other fields unchanged.

Source