Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 2 months 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 (9 months ago)
- Default Branch: master
- Last Pushed: 2024-08-28T21:23:51.000Z (4 months ago)
- Last Synced: 2024-08-28T22:32:08.142Z (4 months ago)
- Topics: go, golang, publish-subscribe, pubsub
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-pubsub
[![PkgGoDev](https://pkg.go.dev/badge/github.com/twpayne/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