control

package
v0.0.0-...-80248e1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallBack

type CallBack struct {
	IParameters
	// contains filtered or unexported fields
}

func NewCallBack

func NewCallBack(onFunction OnFunction, arg ...any) *CallBack

func (*CallBack) Clone

func (p *CallBack) Clone(arg ...any) ICallBack

Clone 创建一个回调对象

func (*CallBack) Equals

func (p *CallBack) Equals(other ICallBack) bool

Equals 比较两个回调是否相等

[❗] 不适用闭包函数. 使用闭包函数比较时,创建新的函数对象,导致比较失败(编译器优化行为可能会掩盖该问题)

func (*CallBack) Execute

func (p *CallBack) Execute() error

type Event

type Event struct {
	ISwitch   ISwitchButton
	ICallBack ICallBack
}

type ICallBack

type ICallBack interface {
	Execute() error             // 执行回调
	IParameters                 // 参数
	Clone(arg ...any) ICallBack // 克隆
}

type IOut

type IOut interface {
	Send(events ...any)
}

IOut 接口 导出

type IParameters

type IParameters interface {
	Override(args ...any) // 覆盖参数
	Get() []any           // 获取参数 [全部]
	Append(args ...any)   // 追加参数
}

IParameters 参数

type ISwitchButton

type ISwitchButton interface {
	On()         // 开
	Off()        // 关
	IsOn() bool  // 是否开
	IsOff() bool // 是否关
}

ISwitchButton 两种状态:开启、关闭

type OnFunction

type OnFunction func(args ...any) error

type Parameters

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

func NewParameters

func NewParameters() *Parameters

func (*Parameters) Append

func (p *Parameters) Append(args ...any)

func (*Parameters) Get

func (p *Parameters) Get() []any

func (*Parameters) Override

func (p *Parameters) Override(args ...any)

type SwitchButton

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

func NewSwitchButton

func NewSwitchButton(state bool) *SwitchButton

func (*SwitchButton) IsOff

func (p *SwitchButton) IsOff() bool

func (*SwitchButton) IsOn

func (p *SwitchButton) IsOn() bool

func (*SwitchButton) Off

func (p *SwitchButton) Off()

func (*SwitchButton) On

func (p *SwitchButton) On()

Jump to

Keyboard shortcuts

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