Documentation
¶
Index ¶
- Variables
- type PomoController
- type PomoControllerContainerIface
- type PomoControllerEventArgsNextState
- type PomoControllerEventArgsPause
- type PomoControllerEventArgsPlay
- type PomoControllerEventArgsStop
- type PomoControllerEventType
- type PomoControllerIface
- type PomoControllerOption
- func PomoControllerDurationF(durationF func() pomoSession.SessionStateDurationFactory) PomoControllerOption
- func PomoControllerOptionErrorSink(errorSink func(err error)) PomoControllerOption
- func PomoControllerOptionNextStateSink(nextStateEventSink func(event PomoControllerEventArgsNextState)) PomoControllerOption
- func PomoControllerOptionPauseSink(pauseEventSink func(event PomoControllerEventArgsPause)) PomoControllerOption
- func PomoControllerOptionPlaySink(playEventSink func(event PomoControllerEventArgsPlay)) PomoControllerOption
- func PomoControllerOptionStopSink(stopEventSink func(event PomoControllerEventArgsStop)) PomoControllerOption
- func PomoControllerSessionOpt(sessionF func() pomoSession.PomoSessionIface) PomoControllerOption
- func PomoControllerTimerOpt(timerF func() pomoTimer.PomoTimerIface) PomoControllerOption
- type PomoControllerState
- type PomoControllerStatus
- type SingleControllerContainer
- type StatusDuration
Constants ¶
This section is empty.
Variables ¶
var ErrExistintgControllerError = errors.New("must remove existing controller")
var ErrNoControllerError = errors.New("must create a controller first")
var ErrPausedTimer = errors.New("cannot execute action on paused timer")
var ErrRunningTimer = errors.New("cannot execute action on running timer")
var ErrStoppedTimer = errors.New("cannot execute action on stopped timer")
Functions ¶
This section is empty.
Types ¶
type PomoController ¶
type PomoController struct {
// contains filtered or unexported fields
}
Main business logic component. Includes session for sequential state management, timer for background state change. It also sends events. pausedAt and end-of-state are for pause and status data.
func ControllerFactory ¶
func ControllerFactory( options ...PomoControllerOption, ) (*PomoController, error)
Aggregator of Pomodoro Controller options and initializes pointer.
func (*PomoController) Pause ¶
func (c *PomoController) Pause(now time.Time) error
Freeze timer in time
func (*PomoController) Play ¶
func (c *PomoController) Play(now time.Time) error
Start paused timer or resume paused timer
func (*PomoController) Skip ¶
func (c *PomoController) Skip(now time.Time) error
Jump to the next status inmediately
func (*PomoController) Status ¶
func (c *PomoController) Status() PomoControllerStatus
Return a status report of the controller
type PomoControllerContainerIface ¶
type PomoControllerContainerIface interface {
GetController() PomoControllerIface
RemoveController()
}
Manages lifecycle of controller object.
type PomoControllerEventArgsNextState ¶
type PomoControllerEventArgsNextState struct {
At time.Time
CurrentState PomoControllerState
NextState PomoControllerState
TimeLeft time.Duration
}
type PomoControllerEventArgsPlay ¶
type PomoControllerEventArgsPlay struct {
At time.Time
CurrentState PomoControllerState
NextState PomoControllerState
CurrentStateDuration time.Duration
}
type PomoControllerEventType ¶
type PomoControllerEventType int
const ( PomoControllerEventTypePlay PomoControllerEventType = iota PomoControllerEventTypeStop PomoControllerEventTypePause PomoControllerEventTypeNextState )
func (PomoControllerEventType) String ¶
func (s PomoControllerEventType) String() string
type PomoControllerIface ¶
type PomoControllerOption ¶
type PomoControllerOption func(*PomoController) (PomoControllerOption, error)
func PomoControllerDurationF ¶
func PomoControllerDurationF( durationF func() pomoSession.SessionStateDurationFactory, ) PomoControllerOption
Sets controller duration factory from factory
func PomoControllerOptionErrorSink ¶
func PomoControllerOptionErrorSink(errorSink func(err error)) PomoControllerOption
Sets error sinks
func PomoControllerOptionNextStateSink ¶
func PomoControllerOptionNextStateSink( nextStateEventSink func(event PomoControllerEventArgsNextState), ) PomoControllerOption
Sets next state sinks
func PomoControllerOptionPauseSink ¶
func PomoControllerOptionPauseSink( pauseEventSink func(event PomoControllerEventArgsPause), ) PomoControllerOption
Sets pause sinks
func PomoControllerOptionPlaySink ¶
func PomoControllerOptionPlaySink( playEventSink func(event PomoControllerEventArgsPlay), ) PomoControllerOption
Sets play sinks
func PomoControllerOptionStopSink ¶
func PomoControllerOptionStopSink( stopEventSink func(event PomoControllerEventArgsStop), ) PomoControllerOption
Sets stop sinks
func PomoControllerSessionOpt ¶
func PomoControllerSessionOpt(sessionF func() pomoSession.PomoSessionIface) PomoControllerOption
Sets controller session from factory
func PomoControllerTimerOpt ¶
func PomoControllerTimerOpt(timerF func() pomoTimer.PomoTimerIface) PomoControllerOption
Sets controller timer from factory
type PomoControllerState ¶
type PomoControllerState int
const ( PomoControllerWork PomoControllerState = iota PomoControllerShortBreak PomoControllerLongBreak PomoControllerPause PomoControllerStopped )
func SessionToControllerState ¶
func SessionToControllerState(s session.PomoSessionStatus) PomoControllerState
func (*PomoControllerState) MarshalJSON ¶
func (s *PomoControllerState) MarshalJSON() ([]byte, error)
func (PomoControllerState) String ¶
func (s PomoControllerState) String() string
func (*PomoControllerState) UnmarshalJSON ¶
func (s *PomoControllerState) UnmarshalJSON(b []byte) error
type PomoControllerStatus ¶
type PomoControllerStatus struct {
State PomoControllerState
TimeLeft *StatusDuration
PausedAt *time.Time
WorkedSessions int
}
type SingleControllerContainer ¶
type SingleControllerContainer struct {
ControllerFactory func() PomoControllerIface
// contains filtered or unexported fields
}
Single reference instance of controller container. Creates instance of controller on first request or after delete. Typically you should call Stop() method on controller to avoid having goroutines open.
func (*SingleControllerContainer) CreateController ¶
func (c *SingleControllerContainer) CreateController() PomoControllerIface
Create new controlle instance. Return error if one already exists
func (*SingleControllerContainer) GetController ¶
func (c *SingleControllerContainer) GetController() PomoControllerIface
Return existing controller. Return error if none exist
func (*SingleControllerContainer) RemoveController ¶
func (c *SingleControllerContainer) RemoveController() error
Remove reference to instance. Return error if none exist.
type StatusDuration ¶
func (*StatusDuration) MarshalJSON ¶
func (s *StatusDuration) MarshalJSON() ([]byte, error)
func (*StatusDuration) UnmarshalJSON ¶
func (d *StatusDuration) UnmarshalJSON(b []byte) error