Documentation
¶
Index ¶
- type Config
- type State
- type Timer
- func (t *Timer) AddSubTimer(id int) error
- func (t *Timer) PauseTimer() error
- func (t *Timer) ResetTimer() error
- func (t *Timer) ResumeTimer() error
- func (t *Timer) SetUpdateInterval(updateInterval int) error
- func (t *Timer) StartTimer() error
- func (t *Timer) StopSubTimer(id int) (time.Duration, error)
- func (t *Timer) StopTimer() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // AllowContinueAfterStop will allow resumeing the timer after it has been stopped AllowResumeAfterStop bool // ContinueCountingWhenStopped sets how the timer behaves after it is resumed after stopping // if set to true the timer will continue counting in the background. For example timer is stopped after 1s and then resumed after 2s. // The timer will now continue counting from 3s instead from 1s. This option exists for accidental stopping of the timer ContinueCountingWhenStopped bool // StopOnSubtimersFinish will stop the timer when all subtimers are set to stop StopOnSubtimersStop bool }
Config allows configuring various settings when creating a new timer
type Timer ¶
type Timer struct { // public State State Updates chan time.Duration // contains filtered or unexported fields }
Timer is the main struct holding all relevant data
func (*Timer) AddSubTimer ¶
AddSubTimer adds a timer with an id to the subtimer pool id has to be unique and can only be added when timer is in reset state
func (*Timer) PauseTimer ¶
PauseTimer timer pauses the timer only possible when in Running state
func (*Timer) ResetTimer ¶
ResetTimer resets the timer to it's default state only possible when in Stopped state
func (*Timer) ResumeTimer ¶
ResumeTimer resumes the timer from a paused state only possible when in Paused or Stopped state
func (*Timer) SetUpdateInterval ¶
SetUpdateInterval sets a new updateInterval for the timer Only works when timer is stopped. Setting 0 for updateInterval sets it back to the default
func (*Timer) StartTimer ¶
StartTimer starts the timer only possible when timer is in Reset state
func (*Timer) StopSubTimer ¶
StopSubTimer will stop a specific subtimer only works when subtimer and timer are running