Documentation ¶
Overview ¶
Package undo provides a doubly linked structure to store a list of actions that can later be reverted or reperformed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Actor ¶
type Actor struct {
// contains filtered or unexported fields
}
Actor encapsulates all undo/redo functionality. Use NewActor() to create an initialized Actor
func (*Actor) AddAction ¶
func (h *Actor) AddAction(id string, a ReversibleAction) error
AddAction performs the action and appends it onto the current node and updates the current node. Will destroy any history ahead of the current node.
type CreateAndInputAction ¶
type CreateAndInputAction struct {
// contains filtered or unexported fields
}
CreateAndInputAction encapsulates adding a new drink to the database and inputting it
func NewCreateAndInputAction ¶
func NewCreateAndInputAction(d model.Drink, de model.DrinkEntry) *CreateAndInputAction
NewCreateAndInputAction returns an initialized CreateAndInputAction
func (*CreateAndInputAction) Do ¶
func (a *CreateAndInputAction) Do() (err error)
Do implements the ReversibleAction interface
func (*CreateAndInputAction) Undo ¶
func (a *CreateAndInputAction) Undo() (err error)
Undo implements the ReversibleAction interface
type CreateDrinkAction ¶
type CreateDrinkAction struct {
// contains filtered or unexported fields
}
CreateDrinkAction encapsulates adding a new drink to the database
func NewCreateDrinkAction ¶
func NewCreateDrinkAction(d model.Drink) *CreateDrinkAction
NewCreateDrinkAction returns an initialized CreateDrinkAction
func (*CreateDrinkAction) Do ¶
func (a *CreateDrinkAction) Do() error
Do implements the ReversibleAction interface
func (*CreateDrinkAction) Undo ¶
func (a *CreateDrinkAction) Undo() error
Undo implements the ReversibleAction interface
type InputDrinksAction ¶
type InputDrinksAction struct {
// contains filtered or unexported fields
}
InputDrinksAction encapsulates stocking a drink
func NewInputDrinksAction ¶
func NewInputDrinksAction(de model.DrinkEntry) *InputDrinksAction
NewInputDrinksAction returns an initialized InputDrinksAction
func (*InputDrinksAction) Do ¶
func (a *InputDrinksAction) Do() error
Do implements the ReversibleAction interface
func (*InputDrinksAction) Undo ¶
func (a *InputDrinksAction) Undo() error
Undo implements the ReversibleAction interface
type OutputDrinksAction ¶
type OutputDrinksAction struct {
// contains filtered or unexported fields
}
OutputDrinksAction encapsulates serving a drink
func NewOutputDrinksAction ¶
func NewOutputDrinksAction(de model.DrinkEntry) *OutputDrinksAction
NewOutputDrinksAction returns an initialized OutputDrinksAction
func (*OutputDrinksAction) Do ¶
func (a *OutputDrinksAction) Do() error
Do implements the ReversibleAction interface
func (*OutputDrinksAction) Undo ¶
func (a *OutputDrinksAction) Undo() error
Undo implements the ReversibleAction interface
type ReversibleAction ¶
ReversibleAction defines an undo-able database change