timer

package
v0.0.0-...-02e020e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package timer provides a simple timeout component.

Index

Constants

View Source
const (
	StateIdle = iota
	StateActive
	StateTimedOut
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	// contains filtered or unexported fields
}

func New

func New() Model

New creates a new timer with the given timeout and nextTick interval.

func (Model) Active

func (m Model) Active() bool

func (Model) ID

func (m Model) ID() int

func (Model) Idle

func (m Model) Idle() bool

func (Model) Remaining

func (m Model) Remaining() time.Duration

Remaining returns the amount of time remaining if the timer is active

func (Model) Reset

func (m Model) Reset() tea.Cmd

Reset resets the timer to idle

func (Model) Start

func (m Model) Start(end time.Time) tea.Cmd

Start starts the timer with the given end time.

func (Model) State

func (m Model) State() State

func (Model) TimedOut

func (m Model) TimedOut() bool

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

func (Model) View

func (m Model) View() string

View of the timer component.

type ResetMsg

type ResetMsg struct {
	// contains filtered or unexported fields
}

type StartMsg

type StartMsg struct {
	// contains filtered or unexported fields
}

type State

type State int

type TickMsg

type TickMsg struct {
	// contains filtered or unexported fields
}

type TimeoutMsg

type TimeoutMsg struct {
	ID int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL