Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
event: expand Subscribe doc
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Jun 21, 2019
1 parent 2d4cac7 commit cee4db9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions event/bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,30 @@ type Subscription interface {
type Bus interface {
// Subscribe creates a new subscription.
//
// EventType must be a pointer to a event type or an array of pointers
//
// Failing to drain the channel may cause publishers to block. CancelFunc must return after
// last send to the channel.
//
// Example:
// Simple Example:
// sub, err := eventbus.Subscribe(new(EventType))
// defer sub.Close()
// for e := range sub.Out() {
// event := e.(EventType) // guaranteed safe
// [...]
// }
// TODO: update doc
//
// Multi-Type Example:
// sub, err := eventbus.Subscribe([]interface{}{new(EventA), new(EventB)})
// defer sub.Close()
// for e := range sub.Out() {
// select e.(type):
// case EventA:
// [...]
// case EventB:
// [...]
// }
// }
Subscribe(eventType interface{}, opts ...SubscriptionOpt) (Subscription, error)

// Emitter creates a new event emitter.
Expand Down

0 comments on commit cee4db9

Please sign in to comment.