notify

package
v0.5.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 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 is the notification centre: core.NotificationService in memory. Posting stores the notification (newest first, at most Max) and publishes core.NotificationPosted; the shell turns that into a toast and a badge on the bell of the status bar.

A centre opened over Documents (Open) keeps its info, success and warning notifications across restarts, until they are cleared; errors belong to the session that had them and are not kept. Saving happens on a goroutine after each change (the newest list wins); Close waits for it.

Imports: core.

Index

Constants

View Source
const DocKey = "notifications"

DocKey is the document the notifications are kept in.

View Source
const Max = 200

Max is how many notifications the centre keeps; older ones drop off.

Variables

This section is empty.

Functions

This section is empty.

Types

type Center

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

Center implements core.NotificationService.

func New

func New(bus *core.Bus) *Center

New returns an empty centre publishing on bus (which may be nil).

func Open

func Open(ctx context.Context, docs Documents, bus *core.Bus) (*Center, error)

Open returns a centre that keeps its notifications in docs, with the ones kept last time. A document that does not decode is ignored (and replaced at the next change): Open then returns the empty centre and the error, for the log.

func (*Center) Clear

func (c *Center) Clear(context.Context) error

Clear removes every notification.

func (*Center) Close

func (c *Center) Close()

Close waits for pending saves (call it before closing the store).

func (*Center) List

func (c *Center) List(context.Context) ([]core.Notification, error)

List returns the notifications, newest first.

func (*Center) MarkRead

func (c *Center) MarkRead(_ context.Context, id string) error

MarkRead marks one notification read; "" marks them all.

func (*Center) Post

func (c *Center) Post(n core.Notification)

Post stores n, filling its ID and Time when empty, and publishes NotificationPosted. A notification with the ID of one stored replaces it (as unread), so a repeated problem shows once. It never blocks.

type Documents

type Documents interface {
	Get(ctx context.Context, key string) ([]byte, bool, error)
	Put(ctx context.Context, key string, doc []byte) error
}

Documents is where a centre keeps its notifications; store.Documents satisfies it.

Jump to

Keyboard shortcuts

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