Browse Source

Some more docs

pull/1681/head
Łukasz Magiera 5 years ago
parent
commit
c476ef6257
  1. 10
      p2p/host/eventbus/interface.go

10
p2p/host/eventbus/interface.go

@ -33,6 +33,12 @@ func Stateful(s *EmitterSettings) {
type Bus interface { type Bus interface {
// Subscribe creates new subscription. Failing to drain the channel will cause // Subscribe creates new subscription. Failing to drain the channel will cause
// publishers to get blocked // publishers to get blocked
//
// Example:
// ch := make(chan EventT, 10)
// defer close(ch)
// cancel, err := eventbus.Subscribe(ch)
// defer cancel()
Subscribe(typedChan interface{}, opts ...SubOption) (CancelFunc, error) Subscribe(typedChan interface{}, opts ...SubOption) (CancelFunc, error)
// Emitter creates new emitter // Emitter creates new emitter
@ -41,8 +47,10 @@ type Bus interface {
// select output type // select output type
// //
// Example: // Example:
// sub, cancel, err := eventbus.Subscribe(new(os.Signal)) // emit, cancel, err := eventbus.Emitter(new(EventT))
// defer cancel() // defer cancel()
//
// emit(EventT{})
Emitter(eventType interface{}, opts ...EmitterOption) (EmitFunc, CancelFunc, error) Emitter(eventType interface{}, opts ...EmitterOption) (EmitFunc, CancelFunc, error)
} }

Loading…
Cancel
Save