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.
Click to show internal directories.
Click to hide internal directories.