Skip to content

Package pubsub is a simple publish-subscribe implementation using generics.

License

Notifications You must be signed in to change notification settings

twpayne/go-pubsub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-pubsub

PkgGoDev

Package pubsub is a simple publish-subscribe implementation using generics.

Example

ctx := context.Background()

topic := pubsub.NewTopic[int](ctx)

ch := make(chan int)
topic.Subscribe(ctx, ch)
go func() {
    defer topic.Close()
    for i := range 3 {
        topic.Publish(ctx, i)
    }
}()

for i := range ch {
    fmt.Println(i)
}

License

MIT

About

Package pubsub is a simple publish-subscribe implementation using generics.

Topics

Resources

License

Stars

Watchers

Forks

Languages