Documentation ¶
Index ¶
- type BatchTarget
- type Notifier
- func (n *Notifier) BatchLevel() int
- func (n *Notifier) Enabled() bool
- func (n *Notifier) EndBatch()
- func (n *Notifier) Notify(name string, producer any)
- func (n *Notifier) NotifyWithData(name string, data, producer any)
- func (n *Notifier) Register(target Target, priority int, names ...string)
- func (n *Notifier) RegisterFromNotifier(other *Notifier)
- func (n *Notifier) Reset()
- func (n *Notifier) SetEnabled(enabled bool)
- func (n *Notifier) StartBatch()
- func (n *Notifier) Unregister(target Target)
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchTarget ¶
type BatchTarget interface { Target // BatchMode is called both before and after a series of notifications are about to be broadcast. The target is not // guaranteed to have intervening calls to HandleNotification() made to it. BatchMode(start bool) }
BatchTarget defines the methods a target of notifications that wants to be notified when a batch change occurs must implement.
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
Notifier tracks targets of notifications and provides methods for notifying them.
func (*Notifier) BatchLevel ¶
BatchLevel returns the current batch level.
func (*Notifier) EndBatch ¶
func (n *Notifier) EndBatch()
EndBatch informs all BatchTargets that were present when StartBatch() was called that a batch of notifications just finished. If batch level is still greater than zero after being decremented, then no notifications will be made.
func (*Notifier) NotifyWithData ¶
NotifyWithData sends a notification to all interested targets. This is a synchronous notification and will not return until all interested targets handle the notification.
func (*Notifier) Register ¶
Register a target with this notifier. 'priority' is the relative notification priority, with higher values being delivered first. 'names' are the names the target wishes to consume. Names are hierarchical (separated by a .), so specifying a name of "foo.bar" will consume not only a produced name of "foo.bar", but all sub-names, such as "foo.bar.a", but not "foo.barn" or "foo.barn.a".
func (*Notifier) RegisterFromNotifier ¶
RegisterFromNotifier adds all registrations from the other notifier into this notifier.
func (*Notifier) SetEnabled ¶
SetEnabled sets whether this notifier is enabled or not.
func (*Notifier) StartBatch ¶
func (n *Notifier) StartBatch()
StartBatch informs all BatchTargets that a batch of notifications will be starting. If a previous call to this method was made without a call to EndBatch(), then the batch level will be incremented, but no notifications will be made.