prefs

package
v0.1.0-rc3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package prefs provides a coalescing preference writer for Spotnik. It batches in-memory preference changes and flushes them to disk in a single debounced write via the Bubble Tea Cmd/Msg pattern.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlushedMsg

type FlushedMsg struct {
	Err error
}

FlushedMsg is emitted after a flush attempt completes. Err is nil on success.

type PreferenceStore

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

PreferenceStore manages in-memory preference state and coalesces writes to disk. It is the single point of truth for runtime preference changes. Thread-safe.

func New

func New(path string) *PreferenceStore

New creates a PreferenceStore targeting the given config file path.

func (*PreferenceStore) FlushCmd

func (s *PreferenceStore) FlushCmd() tea.Cmd

FlushCmd returns a tea.Cmd that writes all pending preferences to disk. It reads the existing config file, applies pending changes to the [preferences] section, and writes it back. Pending map is cleared after a successful write. If nothing is pending, returns a no-op FlushedMsg immediately.

func (*PreferenceStore) HasPending

func (s *PreferenceStore) HasPending() bool

HasPending returns true if there are unsaved preference changes.

func (*PreferenceStore) Set

func (s *PreferenceStore) Set(key string, value any)

Set marks a preference as dirty. The value is held in memory until FlushCmd writes it to disk. Thread-safe — can be called from Update() safely.

Jump to

Keyboard shortcuts

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