https://github.com/twpayne/go-pubsub
Package pubsub is a simple publish-subscribe implementation using generics.
https://github.com/twpayne/go-pubsub
go golang publish-subscribe pubsub
Last synced: 20 days ago
JSON representation
Package pubsub is a simple publish-subscribe implementation using generics.
- Host: GitHub
- URL: https://github.com/twpayne/go-pubsub
- Owner: twpayne
- License: mit
- Created: 2024-04-15T06:58:05.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-09-27T10:20:04.000Z (7 months ago)
- Last Synced: 2025-04-10T13:22:32.065Z (21 days ago)
- Topics: go, golang, publish-subscribe, pubsub
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 8
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-pubsub
[](https://pkg.go.dev/github.com/twpayne/go-pubsub)
Package pubsub is a simple publish-subscribe implementation using generics.
## Example
```go
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