gredux: github.com/johnathanhowell/gredux Index | Files

package gredux

import "github.com/johnathanhowell/gredux"

Index

Package Files

gredux.go

type Action Uses

type Action struct {
    ID   string
    Data interface{}
}

Action defines a dispatchable data type that triggers updates in the Store.

type Reducer Uses

type Reducer func(State, Action) State

Reducer is the func which receives actions dispatched using Store.Dispatch() and updates the internal state.

type State Uses

type State interface{}

State is the state of the gredux Store.

type Store Uses

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 Uses

func New(initialState State) *Store

New instantiates a new gredux Store. initialState should be the struct used to define the Store's state.

func (*Store) AfterUpdate Uses

func (st *Store) AfterUpdate(update func(State))

AfterUpdate sets Store's update func. `update` is called after each dispatch with a copy of the new state.

func (*Store) Dispatch Uses

func (st *Store) Dispatch(action Action)

Dispatch dispatches an Action into the Store.

func (*Store) Reducer Uses

func (st *Store) Reducer(r Reducer)

Reducer sets the store's reducer function to the function `r`.

func (*Store) State Uses

func (st *Store) State() State

State returns a copy of the current state.

Package gredux imports 1 packages (graph). Updated 2018-02-18. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).