track

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package track provides mutation-tracking primitives used by moduli.

End-users import this package only when they need to inspect or stream the history; ordinary option-usage requires nothing beyond the root package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change[T any] struct {
	Name string
}

Change represents a single mutation event (currently just the option name).

type Memory

type Memory[T any] struct {
	// contains filtered or unexported fields
}

Memory tracks all changes in memory and supports change hooks.

func (*Memory[T]) History

func (m *Memory[T]) History() []Change[T]

History returns a copy of all recorded changes.

func (*Memory[T]) JSON

func (m *Memory[T]) JSON() ([]byte, error)

JSON returns the tracked history encoded as JSON.

func (*Memory[T]) RegisterHook

func (m *Memory[T]) RegisterHook(h func(Change[T]))

RegisterHook adds an observer callback that runs after every change.

func (*Memory[T]) Track

func (m *Memory[T]) Track(name string)

Track records a change and notifies all registered hooks. Safe for concurrent callers to use.

type Tracker

type Tracker[T any] interface {
	Track(name string)
}

Tracker is implemented by types that can record before/after mutations.

Jump to

Keyboard shortcuts

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