mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-13 11:36:37 +00:00
Update multisub.go
This commit is contained in:
parent
e58c785424
commit
8026d6dbf1
1 changed files with 7 additions and 0 deletions
|
|
@ -19,6 +19,13 @@ package event
|
||||||
// JoinSubscriptions joins multiple subscriptions to be able to track them as
|
// JoinSubscriptions joins multiple subscriptions to be able to track them as
|
||||||
// one entity and collectively cancel them or consume any errors from them.
|
// one entity and collectively cancel them or consume any errors from them.
|
||||||
func JoinSubscriptions(subs ...Subscription) Subscription {
|
func JoinSubscriptions(subs ...Subscription) Subscription {
|
||||||
|
// Handle empty subscription list to avoid blocking forever
|
||||||
|
if len(subs) == 0 {
|
||||||
|
return NewSubscription(func(unsubbed <-chan struct{}) error {
|
||||||
|
<-unsubbed
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
return NewSubscription(func(unsubbed <-chan struct{}) error {
|
return NewSubscription(func(unsubbed <-chan struct{}) error {
|
||||||
// Unsubscribe all subscriptions before returning
|
// Unsubscribe all subscriptions before returning
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue