notify

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: MIT Imports: 2 Imported by: 3 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package notify models transient notifications and TTL queues for viewkit applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notification

type Notification struct {
	Title    string
	Message  string
	Severity glyph.Severity
}

Notification is a transient user-facing message. Severity uses the shared glyph.Severity vocabulary; theme supplies the colors when rendered.

func Negative

func Negative(title, message string) Notification

Negative builds a negative-severity notification.

func Neutral

func Neutral(title, message string) Notification

Neutral builds a neutral-severity notification.

func Note

func Note(sev glyph.Severity, title, message string) Notification

Note builds a Notification with an explicit severity.

func Positive

func Positive(title, message string) Notification

Positive builds a positive-severity notification.

func Warning

func Warning(title, message string) Notification

Warning builds a warning-severity notification.

type Queue

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

Queue holds pending notifications with wall-clock expiries, capped at a maximum length that never evicts the on-screen head or the newest push.

func NewQueue

func NewQueue(capacity int) *Queue

NewQueue returns a queue holding at most capacity notifications (0 = unbounded).

func (*Queue) Active

func (q *Queue) Active() bool

Active reports whether anything is queued.

func (*Queue) Current

func (q *Queue) Current() (Notification, bool)

Current returns the notification being shown: the oldest unexpired entry.

func (*Queue) Len

func (q *Queue) Len() int

Len returns the number of queued notifications.

func (*Queue) Prune added in v0.0.2

func (q *Queue) Prune(now time.Time)

Prune drops every notification whose expiry is at or before now.

func (*Queue) PushFor added in v0.0.2

func (q *Queue) PushFor(n Notification, now time.Time, d time.Duration)

PushFor enqueues n for d measured from now. Non-positive durations drop n.

func (*Queue) PushUntil added in v0.0.2

func (q *Queue) PushUntil(n Notification, expiry time.Time)

PushUntil enqueues n until an absolute expiry.

func (*Queue) Snapshot added in v0.0.2

func (q *Queue) Snapshot() []Notification

Snapshot copies the queued notifications, oldest first.

Jump to

Keyboard shortcuts

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