actions

package
v19.10.22+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: MIT, MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {

	// ActionLabel returns the name of an action for display in the editor ui.
	ActionLabel() string
	// contains filtered or unexported methods
}

Action is an object that's dispatched to update an agent's state.

type ActionCreator

type ActionCreator func(ActionData) (Action, error)

ActionCreator creates a new action.

func MakeActionCreator

func MakeActionCreator(zero Action) ActionCreator

MakeActionCreator returns an action creator that decodes the ActionData into a copy of zero.

type ActionData

type ActionData struct {
	// Name is the name of the action
	Name string

	// Data is the raw encoded data of the action
	Data codec.Raw

	// Handle is the handle to use for decoding Data
	Handle codec.Handle
}

ActionData is data coming from the client.

func (ActionData) Decode

func (d ActionData) Decode(p interface{}) error

Decode decodes the encoded data into the action pointer p.

type ActionType

type ActionType struct{}

ActionType is the base implementation of an action.

func (ActionType) ActionLabel

func (ActionType) ActionLabel() string

ActionLabel implemented Action.ActionLabel().

type ClientAction

type ClientAction interface {
	ClientAction() ClientData
}

ClientAction is an action that may be sent to the client.

type ClientData

type ClientData struct {
	Name string
	Data interface{}
}

ClientData is the marshal-able form of a ClientAction.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry is a map of known action creators for actions coming from the client

func (*Registry) Lookup

func (r *Registry) Lookup(name string) ActionCreator

Lookup returns the action creator named name or nil if doesn't exist.

func (*Registry) Register

func (r *Registry) Register(name string, zero Action) *Registry

Register is equivalent of RegisterCreator(name, MakeActionCreator(zero)).

func (*Registry) RegisterCreator

func (r *Registry) RegisterCreator(name string, f ActionCreator) *Registry

RegisterCreator registers the action creator f.

NOTE: If a function is already registered with that name, it panics.

Jump to

Keyboard shortcuts

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