Documentation
¶
Overview ¶
Package nodra is a concurrency-safe reactive state store for Go desktop applications.
The root package is the stable public API; implementation details are kept in internal/core. Start with New, Create or NewWithClone, then use Store.Get, Set, Update, UpdateErr, Patch, Reset, Transaction, Batch, BatchErr, Watch, Subscribe, SubscribeWith, SubscribeSnapshot, SubscribeMutations, Do, Action, TaskSnapshot, ActiveTasks and Close. ReadOnly exposes the observation-only surface. Derived values use Derive, DeriveProjection, Combine, Select, SubscribeSelector and SubscribeProjection. Persistence uses NewPersistence, JSONCodec, VersionedJSONCodec, FileStorage, CheckedFileStorage and AESGCMCodec. Async work uses NewAsyncAction, Task and Scope. MyGo redraws use Invalidate, InvalidateTarget, InvalidateSelector and InvalidateProjection.
The public method index and ownership/error contracts are in docs/public-api.md. Go's current generic type-alias documentation omits methods from the Store, History, Persistence and AsyncAction entries, so this package comment intentionally keeps the discoverable method index here too. The v1 support matrix is in docs/support.md.
Index ¶
- Constants
- Variables
- func Atomic2[A, B any](first *Store[A], second *Store[B], fn func(*A, *B) error) error
- func AtomicGroup(ops ...AtomicOp) error
- func Invalidate[T any](source Observable[T], window *mygo.Window) func()
- func InvalidateProjection[T, V any](source Reader[T], window *mygo.Window, project func(T) V) func()
- func InvalidateProjectionWith[T, V any](source Reader[T], window *mygo.Window, project func(T) V, ...) func()
- func InvalidateSelector[T, V any](source Observable[T], window *mygo.Window, selector func(T) V) func()
- func InvalidateSelectorWith[T, V any](source Observable[T], window *mygo.Window, selector func(T) V, ...) func()
- func InvalidateTarget[T any](source Observable[T], target InvalidationTarget) func()
- func SubscribeProjection[T, V any](source Reader[T], project func(T) V, fn func(V)) func()
- func SubscribeProjectionWith[T, V any](source Reader[T], project func(T) V, fn func(current, previous V), ...) func()
- func SubscribeSelector[T, S any](source Observable[T], selector func(T) S, fn func(S)) func()
- func SubscribeSelectorWith[T, V any](source Observable[T], selector func(T) V, fn func(current, previous V), ...) func()
- type AESGCMCodec
- type ActionEvent
- type ActionHooks
- type ActionMetrics
- type ActionOptions
- type ActionPolicy
- type ActionTrace
- type AsyncAction
- type AsyncOptions
- type AsyncPersistence
- type AsyncState
- type AtomicOp
- type CheckedFileStorage
- type Codec
- type Definition
- type Derived
- func Combine[A, B, V any](first Observable[A], second Observable[B], project func(A, B) V, ...) *Derived[Pair[A, B], V]
- func Derive[T, V any](source Observable[T], selector func(T) V, equals func(V, V) bool) *Derived[T, V]
- func DeriveProjection[T, V any](source Reader[T], project func(T) V, equals func(V, V) bool) *Derived[T, V]
- type Field
- type FileConflictError
- type FileFingerprint
- type FileStorage
- type History
- type HistoryOptions
- type HistoryState
- type InvalidationTarget
- type JSONCodec
- type JSONMigration
- type KeyProvider
- type LoadError
- type MemoryKeyProvider
- type MetricsSink
- type Mutation
- type MutationType
- type Observable
- type Pair
- type PanicError
- type Persistence
- type PersistenceOptions
- type PersistenceState
- type ReadOnly
- type Reader
- type RecoveryError
- type RetryOptions
- type Scope
- type SelectorOptions
- type Snapshot
- type Storage
- type Store
- type SubscribeOptions
- type Task
- type TaskMetrics
- type TaskPhase
- type TaskSnapshot
- type VersionedJSONCodec
Constants ¶
const ( LatestWins ActionPolicy = core.LatestWins QueueAll ActionPolicy = core.QueueAll TaskQueued TaskPhase = core.TaskQueued TaskRunning TaskPhase = core.TaskRunning TaskSucceeded TaskPhase = core.TaskSucceeded TaskCanceled TaskPhase = core.TaskCanceled TaskSuperseded TaskPhase = core.TaskSuperseded TaskFailed TaskPhase = core.TaskFailed MutationDirect MutationType = core.MutationDirect MutationPatch MutationType = core.MutationPatch MutationAction MutationType = core.MutationAction MutationReset MutationType = core.MutationReset MutationTransaction MutationType = core.MutationTransaction )
Variables ¶
var ( ErrNoUndo = core.ErrNoUndo ErrNoRedo = core.ErrNoRedo ErrSuperseded = core.ErrSuperseded ErrInvalidAction = core.ErrInvalidAction ErrQueueFull = core.ErrQueueFull ErrUnsupportedVersion = core.ErrUnsupportedVersion ErrMissingMigration = core.ErrMissingMigration ErrClosed = core.ErrClosed ErrFileConflict = core.ErrFileConflict ErrHistoryBatch = core.ErrHistoryBatch ErrHistoryGroup = core.ErrHistoryGroup ErrInvalidBinding = core.ErrInvalidBinding ErrInvalidHistory = core.ErrInvalidHistory ErrInvalidKey = core.ErrInvalidKey ErrInvalidPersistence = core.ErrInvalidPersistence ErrNoBackup = core.ErrNoBackup ErrPersistenceRecovery = core.ErrPersistenceRecovery )
Functions ¶
func AtomicGroup ¶ added in v0.9.0
func AtomicGroup(ops ...AtomicOp) error
func Invalidate ¶ added in v0.2.0
func InvalidateProjection ¶ added in v0.6.0
func InvalidateProjectionWith ¶ added in v0.6.0
func InvalidateSelector ¶ added in v0.5.0
func InvalidateSelectorWith ¶ added in v0.5.0
func InvalidateTarget ¶ added in v0.9.0
func InvalidateTarget[T any](source Observable[T], target InvalidationTarget) func()
func SubscribeProjection ¶ added in v0.6.0
func SubscribeProjection[T, V any](source Reader[T], project func(T) V, fn func(V)) func()
func SubscribeProjectionWith ¶ added in v0.6.0
func SubscribeProjectionWith[T, V any](source Reader[T], project func(T) V, fn func(current, previous V), options SelectorOptions[V]) func()
func SubscribeSelector ¶
func SubscribeSelector[T, S any](source Observable[T], selector func(T) S, fn func(S)) func()
func SubscribeSelectorWith ¶
func SubscribeSelectorWith[T, V any](source Observable[T], selector func(T) V, fn func(current, previous V), options SelectorOptions[V]) func()
Types ¶
type AESGCMCodec ¶ added in v0.9.0
type AESGCMCodec[T any] = core.AESGCMCodec[T]
AESGCMCodec encrypts another codec's bytes with authenticated AES-GCM.
type ActionEvent ¶
type ActionEvent = core.ActionEvent
type ActionHooks ¶
type ActionHooks = core.ActionHooks
type ActionMetrics ¶ added in v0.9.0
type ActionMetrics = core.ActionMetrics
type ActionOptions ¶ added in v0.6.0
type ActionOptions[I any] = core.ActionOptions[I]
type ActionPolicy ¶ added in v0.6.0
type ActionPolicy = core.ActionPolicy
type ActionTrace ¶ added in v0.6.0
type ActionTrace = core.ActionTrace
type AsyncAction ¶ added in v0.6.0
type AsyncAction[T, I, R any] = core.AsyncAction[T, I, R]
func NewAsyncAction ¶ added in v0.6.0
type AsyncOptions ¶ added in v0.3.0
type AsyncOptions = core.AsyncOptions
type AsyncPersistence ¶ added in v0.3.0
type AsyncPersistence[T any] = core.AsyncPersistence[T]
type AsyncState ¶ added in v0.6.0
type AsyncState = core.AsyncState
type AtomicOp ¶ added in v0.9.0
func AtomicUpdate ¶ added in v0.9.0
type CheckedFileStorage ¶ added in v0.7.0
type CheckedFileStorage = core.CheckedFileStorage
type Definition ¶
type Definition[T any] = core.Definition[T]
func DefineWithClone ¶ added in v0.3.0
type FileConflictError ¶ added in v0.7.0
type FileConflictError = core.FileConflictError
type FileFingerprint ¶ added in v0.7.0
type FileFingerprint = core.FileFingerprint
type FileStorage ¶
type FileStorage = core.FileStorage
type HistoryOptions ¶ added in v0.6.0
type HistoryOptions[T any] = core.HistoryOptions[T]
type HistoryState ¶ added in v0.7.0
type HistoryState = core.HistoryState
type InvalidationTarget ¶ added in v0.9.0
type InvalidationTarget = core.InvalidationTarget
type JSONMigration ¶ added in v0.3.0
type JSONMigration = core.JSONMigration
type KeyProvider ¶ added in v0.9.0
type KeyProvider = core.KeyProvider
type MemoryKeyProvider ¶ added in v0.9.0
type MemoryKeyProvider = core.MemoryKeyProvider
func NewMemoryKeyProvider ¶ added in v0.9.0
type MetricsSink ¶ added in v0.9.0
type MetricsSink = core.MetricsSink
type MutationType ¶
type MutationType = core.MutationType
type Observable ¶ added in v0.7.0
type Observable[T any] = core.Observable[T]
type PanicError ¶ added in v0.6.0
type PanicError = core.PanicError
type Persistence ¶
type Persistence[T any] = core.Persistence[T]
Persistence connects a Store to a byte Storage and Codec.
func NewPersistence ¶
func NewPersistence[T any](store *Store[T], storage Storage, codec Codec[T]) *Persistence[T]
func NewPersistenceWithOptions ¶ added in v0.6.0
func NewPersistenceWithOptions[T any](store *Store[T], storage Storage, codec Codec[T], options PersistenceOptions[T]) *Persistence[T]
type PersistenceOptions ¶ added in v0.6.0
type PersistenceOptions[T any] = core.PersistenceOptions[T]
type PersistenceState ¶ added in v0.7.0
type PersistenceState = core.PersistenceState
type RecoveryError ¶ added in v0.9.0
type RecoveryError = core.RecoveryError
type RetryOptions ¶ added in v0.9.0
type RetryOptions = core.RetryOptions
type SelectorOptions ¶
type SelectorOptions[V any] = core.SelectorOptions[V]
type Store ¶
Store owns versioned state and synchronously publishes snapshots to its observers. See Store methods in docs/public-api.md when the Go documentation renderer omits methods for this root-package alias.
func NewWithClone ¶ added in v0.3.0
func NewWithClone[T any](initial T, clone func(T) T) *Store[T]
type SubscribeOptions ¶
type SubscribeOptions[T any] = core.SubscribeOptions[T]
type TaskMetrics ¶ added in v0.7.0
type TaskMetrics = core.TaskMetrics
type TaskSnapshot ¶ added in v0.6.0
type TaskSnapshot = core.TaskSnapshot
type VersionedJSONCodec ¶ added in v0.3.0
type VersionedJSONCodec[T any] = core.VersionedJSONCodec[T]
Directories
¶
| Path | Synopsis |
|---|---|
|
Package devtools provides an opt-in local inspector for Nodra stores.
|
Package devtools provides an opt-in local inspector for Nodra stores. |
|
examples
|
|
|
basic
command
|
|
|
devtools
command
Command devtools runs a counter with a live local inspector.
|
Command devtools runs a counter with a live local inspector. |
|
mygo
command
Example mygo demonstrates two native windows sharing business state with independent redraw subscriptions.
|
Example mygo demonstrates two native windows sharing business state with independent redraw subscriptions. |
|
persistent
command
Command persistent demonstrates cloned state, schema migration and write-behind persistence.
|
Command persistent demonstrates cloned state, schema migration and write-behind persistence. |
|
workbench
command
Command workbench searches real local file names and edits persisted settings.
|
Command workbench searches real local file names and edits persisted settings. |
|
internal
|
|
|
core
Package nodra is a state library for MyGo apps: concurrency-safe reactive stores whose snapshots drive native MyGo views.
|
Package nodra is a state library for MyGo apps: concurrency-safe reactive stores whose snapshots drive native MyGo views. |