subpub

package
v0.0.0-...-d473044 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Default

type Default[KEY ISubPubKey] struct {
	// contains filtered or unexported fields
}

Default 发布订阅器

func NewDefault

func NewDefault[KEY ISubPubKey]() *Default[KEY]

func (*Default[KEY]) Clear

func (p *Default[KEY]) Clear()

func (*Default[KEY]) Publish

func (p *Default[KEY]) Publish(key KEY, args ...any) error

func (*Default[KEY]) Subscribe

func (p *Default[KEY]) Subscribe(key KEY, onFunction xcontrol.OnFunction) error

Subscribe 订阅

[❗] 订阅的回调函数, 不可以是闭包函数.

func (*Default[KEY]) Unsubscribe

func (p *Default[KEY]) Unsubscribe(key KEY, onFunction xcontrol.OnFunction) error

Unsubscribe

[❗] 取消订阅的回调函数, 不可以是闭包函数.

type IPublish

type IPublish[KEY ISubPubKey] interface {
	Publish(key KEY, args ...any) error // 发布
}

type ISubPubKey

type ISubPubKey interface {
	int | int32 | uint32 | int64 | uint64 | string
}

type ISubscribe

type ISubscribe[KEY ISubPubKey] interface {
	Subscribe(key KEY, onFunction xcontrol.OnFunction) error   // 订阅
	Unsubscribe(key KEY, onFunction xcontrol.OnFunction) error // 取消订阅
}

Jump to

Keyboard shortcuts

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