Documentation ¶
Overview ¶
Package stopwatch provides a simple stopwatch component.
Index ¶
- type Model
- func (m Model) Elapsed() time.Duration
- func (m Model) ID() int
- func (m Model) Init() tea.Cmd
- func (m Model) Reset() tea.Cmd
- func (m Model) Running() bool
- func (m Model) Start() tea.Cmd
- func (m Model) Stop() tea.Cmd
- func (m Model) Toggle() tea.Cmd
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) View() string
- type ResetMsg
- type StartStopMsg
- type TickMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model struct { // How long to wait before every tick. Defaults to 1 second. Interval time.Duration // contains filtered or unexported fields }
Model for the stopwatch component.
func NewWithInterval ¶
NewWithInterval creates a new stopwatch with the given timeout and tick interval.
type StartStopMsg ¶
type StartStopMsg struct { ID int // contains filtered or unexported fields }
StartStopMsg is sent when the stopwatch should start or stop.
type TickMsg ¶
type TickMsg struct { // ID is the identifier of the stopwatch that sends the message. This makes // it possible to determine which stopwatch a tick belongs to when there // are multiple stopwatches running. // // Note, however, that a stopwatch will reject ticks from other // stopwatches, so it's safe to flow all TickMsgs through all stopwatches // and have them still behave appropriately. ID int }
TickMsg is a message that is sent on every timer tick.
Click to show internal directories.
Click to hide internal directories.