Documentation
¶
Overview ¶
Package notify models transient notifications and TTL queues for viewkit applications.
Index ¶
- type Notification
- type Queue
- func (q *Queue) Active() bool
- func (q *Queue) Current() (Notification, bool)
- func (q *Queue) Len() int
- func (q *Queue) Prune(now time.Time)
- func (q *Queue) PushFor(n Notification, now time.Time, d time.Duration)
- func (q *Queue) PushUntil(n Notification, expiry time.Time)
- func (q *Queue) Snapshot() []Notification
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Notification ¶
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 (*Queue) Current ¶
func (q *Queue) Current() (Notification, bool)
Current returns the notification being shown: the oldest unexpired entry.
func (*Queue) Prune ¶ added in v0.0.2
Prune drops every notification whose expiry is at or before now.
func (*Queue) PushFor ¶ added in v0.0.2
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.