subscribers

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New[T any]() subscribers[T]

Create new subscriber pool to handle jrpc.subscriptions.

Example where single user.ID can havel multiple connections receiving User updates. It's possible instead of user.ID to use any other string (i.e. order.ID) to receive User updates.

// Outside of subscription
s := subscribers.New[User]()

// In subscription
ch := make(chan User)
chId := s.Register(User.ID, ch)
defer func() {
	close(ch)
	s.Delete(User.ID, chId)
}()

// for { subscription handler }

Types

This section is empty.

Jump to

Keyboard shortcuts

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