behavioral

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker[D interface{}, R interface{}] struct {
	Handlers list.List
}

func NewBroker

func NewBroker[D interface{}, R interface{}]() *Broker[D, R]

func (*Broker[D, R]) Fire

func (b *Broker[D, R]) Fire(q *Query[D, R])

func (*Broker[D, R]) Subscribe

func (b *Broker[D, R]) Subscribe(o Handler[D, R])

func (*Broker[D, R]) Unsubscribe

func (b *Broker[D, R]) Unsubscribe(o Handler[D, R])

type Caretaker

type Caretaker[T interface{}] struct {
	MementoArray []*Memento[T]
}

func (*Caretaker[T]) AddMemento

func (c *Caretaker[T]) AddMemento(m *Memento[T])

func (*Caretaker[T]) GetMemento

func (c *Caretaker[T]) GetMemento(index int) *Memento[T]

type Component

type Component[T Mediator] struct {
	Mediator *T
}

func (*Component[T]) Register

func (c *Component[T]) Register(m *T)

type Handler

type Handler[D interface{}, R interface{}] interface {
	Handle(*Query[D, R])
}

type InvalidStateError

type InvalidStateError struct{}

type InvalidTransitionError

type InvalidTransitionError struct {
	Current, Desired *State
	// contains filtered or unexported fields
}

func (*InvalidTransitionError) Error

func (e *InvalidTransitionError) Error() string

type Iterable

type Iterable interface{}

type Iterator

type Iterator[T Iterable] struct {
	Item *T
	// contains filtered or unexported fields
}

func (*Iterator[T]) Extend

func (i *Iterator[T]) Extend(n *Iterator[T])

func (*Iterator[T]) HasNext

func (i *Iterator[T]) HasNext() bool

func (*Iterator[T]) InitIterator

func (i *Iterator[T]) InitIterator() func() *Iterator[T]

func (*Iterator[T]) Last

func (i *Iterator[T]) Last() *Iterator[T]

func (*Iterator[T]) Penultimate

func (i *Iterator[T]) Penultimate() *Iterator[T]

func (*Iterator[T]) SetNext

func (i *Iterator[T]) SetNext(n *Iterator[T])

type Mediator

type Mediator interface{}

type Memento

type Memento[T interface{}] struct {
	State T
}

func (*Memento[T]) GetSavedState

func (m *Memento[T]) GetSavedState() T

type Observable

type Observable[T Observer] struct {
	Subs *list.List
}

func NewObservable

func NewObservable[T Observer]() Observable[T]

func (*Observable[T]) Notify

func (o *Observable[T]) Notify(data interface{})

func (*Observable[T]) Subscribe

func (o *Observable[T]) Subscribe(sub Observer)

func (*Observable[T]) Unsubscribe

func (o *Observable[T]) Unsubscribe(sub Observer)

type Observer

type Observer interface {
	Notify(data interface{})
}

type Originator

type Originator[T interface{}] struct {
	State T
}

func (*Originator[T]) CreateMemento

func (e *Originator[T]) CreateMemento() *Memento[T]

func (*Originator[T]) GetState

func (e *Originator[T]) GetState() T

func (*Originator[T]) RestoreMemento

func (e *Originator[T]) RestoreMemento(m *Memento[T])

func (*Originator[T]) SetState

func (e *Originator[T]) SetState(state T)

type Query

type Query[D interface{}, R interface{}] struct {
	Data   D
	Result R
	Error  error
}

type State

type State int

func (*State) String

func (state *State) String(stateToString *map[State]string) string

type StateMachine

type StateMachine struct {
	CurrentState    State
	TransitionRules *map[State][]State

	MaxUnreachableState State
	// contains filtered or unexported fields
}

func (*StateMachine) GoTo

func (stateMachine *StateMachine) GoTo(desiredState State) error

func (*StateMachine) String

func (stateMachine *StateMachine) String() string

type StateMachineBuilder

type StateMachineBuilder struct {
	creational.FunctionalBuilder[StateMachine]
}

func (*StateMachineBuilder) SetCurrentState

func (builder *StateMachineBuilder) SetCurrentState(initialState State) *StateMachineBuilder

func (*StateMachineBuilder) SetMaxUnreachableState

func (builder *StateMachineBuilder) SetMaxUnreachableState(MaxUnreachableState State) *StateMachineBuilder

func (*StateMachineBuilder) SetStateToString

func (builder *StateMachineBuilder) SetStateToString(stateToString *map[State]string) *StateMachineBuilder

func (*StateMachineBuilder) SetTransitionRules

func (builder *StateMachineBuilder) SetTransitionRules(transitionRules *map[State][]State) *StateMachineBuilder

type StrategyApplicant

type StrategyApplicant interface{}

type StrategyCreatorHandler

type StrategyCreatorHandler[T StrategyApplicant] func() *T

type StrategyHandler

type StrategyHandler[T StrategyApplicant] func(T)

func NewStrategyHandler

func NewStrategyHandler[T StrategyApplicant](handler func(T)) StrategyHandler[T]

type StrategyInstance

type StrategyInstance[T StrategyApplicant] interface {
	Execute()
}

type StrategyMethodHandler

type StrategyMethodHandler[T StrategyApplicant] func()

Jump to

Keyboard shortcuts

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