stopwatch

package
v0.9.2 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 stopwatch provides a simple stopwatch 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 to wait before every tick. Defaults to 1 second.
	Interval time.Duration
	// contains filtered or unexported fields
}

Model of the timer component.

func New

func New() Model

New creates a new stopwatch with 1s interval.

func NewWithInterval

func NewWithInterval(interval time.Duration) Model

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

func (Model) Elapsed

func (m Model) Elapsed() time.Duration

Elapsed returns the time elapsed.

func (Model) Init

func (m Model) Init() tea.Cmd

Init starts the stopwatch..

func (Model) Reset

func (m Model) Reset() tea.Cmd

Reset restes the stopwatch to 0.

func (Model) Running

func (m Model) Running() bool

Running returns true if the stopwatch is running or false if it is stopped.

func (Model) Start

func (m Model) Start() tea.Cmd

Start starts the stopwatch.

func (Model) Stop

func (m Model) Stop() tea.Cmd

Stop stops the stopwatch.

func (Model) Toggle

func (m Model) Toggle() tea.Cmd

Toggle stops the stopwatch if it is running and starts it if it is stopped.

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.

Jump to

Keyboard shortcuts

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