timer

package
v0.9.11 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package timer provides a simple timeout component.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	// How long until the timer expires.
	Timeout time.Duration

	// How long to wait before every tick. Defaults to 1 second.
	Interval time.Duration
}

Model of the timer component.

func New

func New(timeout time.Duration) Model

New creates a new timer with the given timeout and default 1s interval.

func NewWithInterval

func NewWithInterval(timeout, interval time.Duration) Model

NewWithInterval creates a new timer with the given timeout and tick interval.

func (Model) Init

func (m Model) Init() tea.Cmd

Init starts the timer.

func (Model) Update

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

Update handles the timer tick.

func (Model) View

func (m Model) View() string

View of the timer component.

type TickMsg

type TickMsg struct{}

TickMsg is a message that is sent on every timer tick.

type TimeoutMsg

type TimeoutMsg struct{}

TimeoutMsg is a message that is sent once when the timer times out.

Jump to

Keyboard shortcuts

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