barista.run: barista.run/base/notifier Index | Files

package notifier

import "barista.run/base/notifier"

Package notifier provides a channel that can send update notifications. Specifically, a notifier automatically coalesces multiple notifications such that if a previous notification is already pending, a new notification will not be created. This is useful in scenarios like formatting changes, where if multiple updates come in before the first one is processed, it is preferable to apply just the final format, ignoring the intermediate ones.

Index

Package Files

notifier.go

func New Uses

func New() (func(), <-chan struct{})

New constructs a new notifier. It returns a func that triggers a notification, and a <-chan that consumes these notifications.

type Source Uses

type Source struct {
    // contains filtered or unexported fields
}

Source can be used to notify multiple listeners of a signal. It provides both one-shot listeners that close the channel on the next signal, and continuous listeners that emit a struct{} on every signal (but need to be cleaned up).

func (*Source) Next Uses

func (s *Source) Next() <-chan struct{}

Next returns a channel that will be closed on the next signal.

func (*Source) Notify Uses

func (s *Source) Notify()

Notify notifies all interested listeners.

func (*Source) Subscribe Uses

func (s *Source) Subscribe() (sub <-chan struct{}, done func())

Subscribe returns a channel that will receive an empty struct{} on the next signal, and a func to close the subscription.

Package notifier imports 2 packages (graph) and is imported by 15 packages. Updated 2018-11-25. Refresh now. Tools for package owners.