mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-20 17:16:46 +00:00
GODT-35: New pmapi client and manager using resty
This commit is contained in:
23
pkg/pmapi/observer.go
Normal file
23
pkg/pmapi/observer.go
Normal file
@ -0,0 +1,23 @@
|
||||
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() }
|
||||
Reference in New Issue
Block a user