Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 500 Bytes

README.md

File metadata and controls

30 lines (21 loc) · 500 Bytes

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