Files
proton-bridge/pkg/pmapi/observer.go
2021-04-30 05:34:36 +02:00

24 lines
540 B
Go

package pmapi
type ConnectionObserver interface {
OnDown()
OnUp()
}
type observer struct {
onDown, onUp func()
}
// NewConnectionObserver is a helper function to create a new connection observer from two callbacks.
// It doesn't need to be used; anything which implements the ConnectionObserver interface can be an observer.
func NewConnectionObserver(onDown, onUp func()) ConnectionObserver {
return &observer{
onDown: onDown,
onUp: onUp,
}
}
func (o observer) OnDown() { o.onDown() }
func (o observer) OnUp() { o.onUp() }