include existing logic

This commit is contained in:
2024-08-06 15:15:21 +01:00
parent 5d9e4bdd89
commit 1186e69121
7 changed files with 326 additions and 0 deletions

11
wrappers.go Normal file
View File

@@ -0,0 +1,11 @@
package gubgub
// Forever wrapper makes it more explicit that a subscriber will never stop consuming messages.
// This helps avoiding subscribers that always return true which, depending on their size, might
// not be immediately clear.
func Forever[T any](fn func(T)) Subscriber[T] {
return func(msg T) bool {
fn(msg)
return true
}
}