notifier

package
v0.0.0-...-290cb81 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 2 Imported by: 15

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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.

Types

type Source

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

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

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

func (*Source) Notify

func (s *Source) Notify()

Notify notifies all interested listeners.

func (*Source) Subscribe

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL