Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
werbenhu committed Apr 27, 2023
1 parent fe54ec4 commit 946f184
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func main() {
## Use Pipe instead of channel

Pipe is a wrapper for a channel without the concept of topics, with the generic parameter corresponding to the type of the channel. `eventbus.NewPipe[T]()` is equivalent to `make(chan T)`. Publishers publish messages, and subscribers receive messages. You can use the `Pipe.Publish()` method instead of `chan <-`, and the `Pipe.Subscribe()` method instead of `<-chan`.

If there are multiple subscribers, each subscriber will receive every message that is published.If you want to use a buffered channel, you can use the `eventbus.NewBufferedPipe[T](bufferSize int)` method to create a buffered pipe.Pipe also supports synchronous and asynchronous message publishing. If you need to use the synchronous method, call `Pipe.PublishSync()`.

#### pipe example
Expand Down

0 comments on commit 946f184

Please sign in to comment.