-
Notifications
You must be signed in to change notification settings - Fork 218
/
use.go
33 lines (27 loc) · 842 Bytes
/
use.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package notify
import (
"github.com/nikoksr/notify/service/pseudo"
)
// useService adds a given service to the notifiers services list. If the list still contains
// a pseudo service we remove it before adding the 'real' service.
func (n *Notify) useService(service Notifier) {
if service == nil {
return
}
// Remove pseudo service in case a 'real' service will be added
if len(n.notifiers) > 0 {
_, isPseudo := n.notifiers[0].(*pseudo.Pseudo)
if isPseudo {
n.notifiers = n.notifiers[1:]
}
}
n.notifiers = append(n.notifiers, service)
}
// usePseudo adds a pseudo notification service to the notifiers services list.
func (n *Notify) usePseudo() {
n.useService(pseudo.New())
}
// UseService adds a given service to the notifiers services list.
func (n *Notify) UseService(service Notifier) {
n.useService(service)
}