Documentation ¶
Overview ¶
Package state contains utilities for managing state transitions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Change ¶
type Change interface { Apply() Revert() }
Change represents a state change.
func AccumActionChange ¶
AccumActionChange is similar to ActionChange except that it is also extendable. The accumDuration interval is used to specify accumulation threshold for the change.
func ActionChange ¶
ActionChange returns a Change that is based on the specified forward and reverse actions.
func CombinedChange ¶
CombinedChange creates a composite change off of a number of smaller changes.
type ExtendableChange ¶
type ExtendableChange interface { // Extend returns whether the specified change was merged into the current // one. Extend(change Change) bool }
ExtendableChange represents a change that can be extended (e.g. editbox write).
type History ¶
type History struct {
// contains filtered or unexported fields
}
History tracks the sequence of changes and allows for undo and redo.
func NewHistory ¶
NewHistory creates a new History instance with the specified capacity, which determines the maximum amount of changes that will be tracked.
func (*History) LastChange ¶
LastChange returns the last applied change, if there is one, otherwise it returns nil.