Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct { ID string Data interface{} }
Action defines a dispatchable data type that triggers updates in the Store.
type Reducer ¶
Reducer is the func which receives actions dispatched using Store.Dispatch() and updates the internal state.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store defines an immutable store of state. The current state of the Store can be received by calling State() but the state can only be changed by a Reducer as the result of a Dispatch'd Action.
func New ¶
New instantiates a new gredux Store. initialState should be the struct used to define the Store's state.
func (*Store) AddHook ¶
AddHook adds a hook which is invoked for specific actions that are specified as second argument The hook must not dispatch another actions otherwise deadlock will happen!
func (*Store) AddReducer ¶
AddReducer sets the store's reducers function to the function `r`.
func (*Store) AfterUpdate ¶
AfterUpdate sets Store's update func. `update` is called after each dispatch with a copy of the new state.