timer

package module
v0.0.0-...-a696f41 Latest Latest
Warning

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

Go to latest
Published: May 17, 2019 License: MIT Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

golang-timer

Features:

  • pause
  • resume

Package was created to be used along with frontend application across websockets.

Play with example https://play.golang.org/p/SlltwU52so2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Duration       time.Duration
	Passed         time.Duration
	TickerInternal time.Duration
	OnPaused       func()
	OnDone         func(stopped bool)
	OnTick         func()
	OnRun          func(started bool)
}

Options represents configuration for timer.

type Timer

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

Timer represents timer with pause/resume features.

func New

func New(options Options) *Timer

New creates instance of timer.

func (Timer) Passed

func (c Timer) Passed() time.Duration

Passed returns how much done is already passed.

func (*Timer) Pause

func (c *Timer) Pause()

Pause temporarily pauses active timer.

func (Timer) Remaining

func (c Timer) Remaining() time.Duration

Remaining returns how much time is left to end.

func (*Timer) Run

func (c *Timer) Run()

Run starts just created timer and resumes paused.

func (*Timer) Stop

func (c *Timer) Stop()

Stop finishes the timer.

Jump to

Keyboard shortcuts

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