observer

package
v0.0.0-...-a7c7adb Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalTimeService = NewMockTimeService(1800)

Functions

This section is empty.

Types

type AlarmClock

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

func NewAlarmClock

func NewAlarmClock(name string, hour int, minute int, repeatable bool) *AlarmClock

func (*AlarmClock) ID

func (ac *AlarmClock) ID() string

func (*AlarmClock) NextAlarmTime

func (ac *AlarmClock) NextAlarmTime() *time.Time

func (*AlarmClock) Occurs

func (ac *AlarmClock) Occurs() int

func (*AlarmClock) TimeElapsed

func (ac *AlarmClock) TimeElapsed(now *time.Time)

type ITimeObserver

type ITimeObserver interface {
	ID() string
	TimeElapsed(now *time.Time)
}

定义时间观察者接口, 接收时间变化事件的通知

type ITimeService

type ITimeService interface {
	Attach(observer ITimeObserver) //注册
	Detach(id string)              // 注销
}

定义时间服务的接口, 接受观察者的注册和注销

func NewMockTimeService

func NewMockTimeService(speed int64) ITimeService

Jump to

Keyboard shortcuts

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