Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotReceiver = errors.New("not implement receiver interface") ErrNotCommand = errors.New("not implement Command interface") ErrNotUndoCommand = errors.New("not implement UndoCommand interface") ErrNotRedoCommand = errors.New("not implement RedoCommand interface") )
var ( ErrNotFoundUndoCommand = errors.New("not found command in undo command stack") ErrNotFoundRedoCommand = errors.New("not found command in redo command stack") )
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command interface { // Execute a unit of processing work to be performed Execute(ctx context.Context) (context.Context, error) }
A Command encapsulates a unit of processing work to be performed.
func Chain ¶
func Chain(cmd Command, middlewares ...Middleware) Command
Chain decorates the given Command with all middlewares.
type CommandFunc ¶
The CommandFunc type is an adapter to allow the use of ordinary functions as Command. If f is a function with the appropriate signature, CommandFunc(f) is a Command that calls f.
type ConcreteCommand ¶
type ConcreteCommand struct {
// contains filtered or unexported fields
}
func NewConcreteCommand ¶
func NewConcreteCommand(receiver Receiver) *ConcreteCommand
type Middleware ¶
type Middleware interface { // Decorate wraps the underlying Command, adding some functionality. Decorate(cmd Command) Command }
Middleware allows us to write something like decorators to Command. It can execute something before Execute or after.
type MiddlewareFunc ¶
The MiddlewareFunc type is an adapter to allow the use of ordinary functions as Middleware. If f is a function with the appropriate signature, MiddlewareFunc(f) is a Middleware that calls f.
func (MiddlewareFunc) Decorate ¶
func (f MiddlewareFunc) Decorate(cmd Command) Command
Decorate call f(cmd).
type RedoCommand ¶
RedoCommand redo a Command
type RedoCommandFunc ¶
The RedoCommandFunc type is an adapter to allow the use of ordinary functions as RedoCommand. If f is a function with the appropriate signature, RedoCommandFunc(f) is a RedoCommand that calls f.
type RichCommand ¶
type RichCommand struct {
// contains filtered or unexported fields
}
func NewRichCommand ¶
func NewRichCommand(cmd Command, undoCmd UndoCommand, redoCmd RedoCommand) *RichCommand
type UndoCommand ¶
UndoCommand undo a Command
type UndoCommandFunc ¶
The UndoCommandFunc type is an adapter to allow the use of ordinary functions as UndoCommand. If f is a function with the appropriate signature, UndoCommandFunc(f) is a UndoCommand that calls f.