Versions in this module Expand all Collapse all v0 v0.2.0 Oct 21, 2026 Changes in this version + func Invalidate[T any](store *Store[T], window *mygo.Window) (stop func()) v0.1.0 Oct 21, 2026 Changes in this version + var ErrClosed = errors.New("nodra: store is closed") + var ErrInvalidPersistence = errors.New("nodra: invalid persistence configuration") + var ErrNoRedo = errors.New("nodra: nothing to redo") + var ErrNoUndo = errors.New("nodra: nothing to undo") + func SubscribeSelectorWith[T any, V comparable](store *Store[T], selector func(T) V, fn func(current, previous V), ...) func() + func SubscribeSelector[T any, S comparable](store *Store[T], selector func(T) S, fn func(S)) func() + type ActionEvent struct + Duration time.Duration + Err error + Finished time.Time + Name string + Started time.Time + StoreID string + type ActionHooks struct + After func(ActionEvent) + Before func(ActionEvent) + Error func(ActionEvent) + type Codec interface + Decode func([]byte) (T, error) + Encode func(T) ([]byte, error) + type Definition struct + func Define[T any](id string, initial func() T) *Definition[T] + func (d *Definition[T]) ID() string + func (d *Definition[T]) New() *Store[T] + type Derived struct + func Derive[T any, V any](store *Store[T], selector func(T) V, equals func(V, V) bool) *Derived[T, V] + func (d *Derived[T, V]) Close() error + func (d *Derived[T, V]) Get() V + func (d *Derived[T, V]) Subscribe(fn func(V)) func() + type FileStorage struct + Path string + Perm os.FileMode + func (f FileStorage) Load(ctx context.Context) ([]byte, error) + func (f FileStorage) Save(ctx context.Context, data []byte) (err error) + type History struct + func Track[T any](store *Store[T], limit int) *History[T] + func (h *History[T]) CanRedo() bool + func (h *History[T]) CanUndo() bool + func (h *History[T]) Close() error + func (h *History[T]) Redo() error + func (h *History[T]) Undo() error + type JSONCodec struct + func (JSONCodec[T]) Decode(data []byte) (T, error) + func (JSONCodec[T]) Encode(value T) ([]byte, error) + type Mutation struct + At time.Time + Name string + Previous T + Type MutationType + Value T + Version uint64 + type MutationType string + const MutationAction + const MutationDirect + const MutationPatch + const MutationReset + type Persistence struct + func NewPersistence[T any](store *Store[T], storage Storage, codec Codec[T]) *Persistence[T] + func (p *Persistence[T]) AutoSave(ctx context.Context) func() + func (p *Persistence[T]) AutoSaveWithErrors(ctx context.Context) (<-chan error, func()) + func (p *Persistence[T]) Load(ctx context.Context) error + func (p *Persistence[T]) Save(ctx context.Context) error + type SelectorOptions struct + Equals func(previous, next V) bool + Immediate bool + type Snapshot struct + Value T + Version uint64 + type Storage interface + Load func(context.Context) ([]byte, error) + Save func(context.Context, []byte) error + type Store struct + func Create[T any](initial T) *Store[T] + func New[T any](initial T) *Store[T] + func (s *Store[T]) Action(name string, fn func(*T) error) func() error + func (s *Store[T]) Batch(fn func()) error + func (s *Store[T]) Close() error + func (s *Store[T]) Do(name string, fn func(*T) error) error + func (s *Store[T]) Get() T + func (s *Store[T]) ID() string + func (s *Store[T]) Patch(fn func(*T)) error + func (s *Store[T]) Reset() error + func (s *Store[T]) Set(value T) error + func (s *Store[T]) Snapshot() Snapshot[T] + func (s *Store[T]) State() T + func (s *Store[T]) Subscribe(fn func(Snapshot[T])) func() + func (s *Store[T]) SubscribeActionHooks(hooks ActionHooks) func() + func (s *Store[T]) SubscribeActions(fn func(ActionEvent)) func() + func (s *Store[T]) SubscribeMutations(fn func(Mutation[T])) func() + func (s *Store[T]) SubscribeWith(options SubscribeOptions[T], fn func(Snapshot[T])) func() + func (s *Store[T]) Transaction(fn func(*T) error) error + func (s *Store[T]) Update(fn func(*T)) error + func (s *Store[T]) UpdateErr(fn func(*T) error) error + func (s *Store[T]) Version() uint64 + func (s *Store[T]) Watch(ctx context.Context, buffer int) <-chan Snapshot[T] + type SubscribeOptions struct + Equals func(previous, next T) bool + Immediate bool