subscribe

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package subscribe manages subscriptions to all or specific go structs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SubscribeManager

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

SubscribeManager maintains lists of subscribers to specific or all structs.

func New

func New() *SubscribeManager

New returns a pointer to a new SubscribeManager.

func (*SubscribeManager) HandleStruct added in v0.0.2

func (s *SubscribeManager) HandleStruct(p any)

HandleStruct calls registered subscriber callbacks for a struct. It calls all specific subscribers and all subscribers.

func (*SubscribeManager) SubscribeToAllStructs

func (s *SubscribeManager) SubscribeToAllStructs(callback any) (SubscriptionId, error)

SubscribeToAllStructs registers a subscription to all structs. It validates the callback is a func with an any argument.

func (*SubscribeManager) SubscribeToStruct

func (s *SubscribeManager) SubscribeToStruct(t any, callback any) (SubscriptionId, error)

SubscribeToStruct registers a subscription to the specified struct. It validates the callback is a function with a matching argument type.

func (*SubscribeManager) Unsubscribe

func (s *SubscribeManager) Unsubscribe(subId SubscriptionId) error

Unsubscribe cancels a subscription.

type SubscriptionId

type SubscriptionId uint

SubscriptionId identifies a specific subscriber.

Jump to

Keyboard shortcuts

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