## Index

### Classes

- Updux

### Interfaces

- UpduxMiddlewareAPI

### Type aliases

- Action
- ActionCreator
- ActionPair
- ActionPayloadGenerator
- Dictionary
- Dux
- MaybePayload
- Mutation
- Next
- StoreWithDispatchActions
- SubMutations
- UpduxConfig
- UpduxDispatch
- UpduxMiddleware
- Upreducer

### Functions

- MiddlewareFor
- actionCreator
- actionFor
- buildActions
- buildCreateStore
- buildInitial
- buildMiddleware
- buildMutations
- buildUpreducer
- composeMutations
- sliceMw

## Type aliases

### Action

Action<T, P>: object & MaybePayload <P>

- Defined in types.ts:9

#### Type parameters

- #### T: string

- #### P

### ActionCreator

ActionCreator<T, P>: object & function

- Defined in types.ts:22

#### Type parameters

- #### T: string

- #### P

### ActionPair

ActionPair: [string, ActionCreator ]

- Defined in buildActions/index.ts:33

### ActionPayloadGenerator

ActionPayloadGenerator: function

- Defined in types.ts:20

#### Type declaration

- - (...args: any[]): any

  - #### Parameters

    - ##### Rest ...args: any[]

    #### Returns any

### Dictionary

Dictionary<T>: object

- Defined in types.ts:13

#### Type parameters

- #### T

#### Type declaration

- ##### [key: string]: T

### Dux

Dux<S>: Pick< Updux <S>, "subduxes" | "actions" | "initial" | "mutations" | "reducer" | "middleware" | "createStore" | "upreducer">

- Defined in updux.ts:33

#### Type parameters

- #### S

### MaybePayload

MaybePayload<P>: MaybePayload<P>

- Defined in types.ts:3

#### Type parameters

- #### P

### Mutation

Mutation<S, A>: function

- Defined in types.ts:15

#### Type parameters

- #### S

- #### A: Action

#### Type declaration

- - (payload: A["payload"], action: A): function

  - #### Parameters

    - ##### payload: A["payload"]

    - ##### action: A

    #### Returns function

    - - (state: S): S

      - #### Parameters

        - ##### state: S

        #### Returns S

### Next

Next: function

- Defined in buildMiddleware/index.ts:12

#### Type declaration

- - (action: Action ): any

  - #### Parameters

    - ##### action: Action

    #### Returns any

### StoreWithDispatchActions

StoreWithDispatchActions<S, Actions>: Store<S> & object

- Defined in updux.ts:26

#### Type parameters

- #### S

- #### Actions

### SubMutations

SubMutations: object

- Defined in buildMutations/index.ts:10

#### Type declaration

- ##### [slice: string]: Dictionary < Mutation >

### UpduxConfig

UpduxConfig<S>: object

- Defined in types.ts:34

Configuration object given to Updux's constructor.

#### Type parameters

- #### S

  Type of the Updux's state. Defaults to `any`.

#### Type declaration

- ##### Optional actions?: undefined | object

  Generic action creations are automatically created from the mutations and effects, but you can also define custom action creator here. The object's values are function that transform the arguments of the creator to the action's payload.

      const { actions } = updox({
          mutations: {
              foo: () => state => state,
          }
          actions: {
              bar: (x,y) => ({x,y})
          }
      });

      actions.foo({ x: 1, y: 2 }); // => { type: foo, payload: { x:1, y:2  } }
      actions.bar(1,2);            // => { type: bar, payload: { x:1, y:2  } }

- ##### Optional effects?: Dictionary < UpduxMiddleware <S>>

  Plain object defining asynchronous actions and side-effects triggered by actions. The effects themselves are Redux middleware, expect with the `dispatch` property of the first argument augmented with all the available actions.

      updux({
          effects: {
              fetch: ({dispatch}) => next => async (action) => {
                  next(action);

                  let result = await fetch(action.payload.url).then( result => result.json() );
                  dispatch.fetchSuccess(result);
              }
          }
      });

- ##### Optional groomMutations?: undefined | function

- ##### Optional initial?: S

  The default initial state of the reducer. Can be anything your heart desires.

- ##### Optional mutations?: any

  Object mapping actions to the associated state mutation.

  For example, in `Redux` you'd do

      function todosReducer(state=[],action) {

          switch(action.type) {
              case 'ADD':  return [ ...state, action.payload ];

              case 'DONE': return state.map( todo => todo.id === action.payload
                  ? { ...todo, done: true } : todo )

              default: return state;
          }
      }

  With Updux:

      const todosUpdux = updux({
          mutations: {
              add: todo => state => [ ...state, todo ],
              done: done_id => u.map( u.if( ({id} => id === done_id), {done: true} ) )
          }
      });

  The signature of the mutations is `(payload,action) => state => newState`. It is designed to play well with `Updeep` (and Immer). This way, instead of doing

          mutation: {
              renameTodo: newName => state => { ...state, name: newName }
          }

  we can do

          mutation: {
              renameTodo: newName => u({ name: newName })
          }

  Also, the special key `*` can be used to match any action not explicitly matched by other mutations.

      const todosUpdux = updux({
          mutations: {
              add: todo => state => [ ...state, todo ],
              done: done_id => u.map( u.if( ({id} => id === done_id), {done: true} ) ),
              '*' (payload,action) => state => {
                  console.warn( "unexpected action ", action.type );
                  return state;
              },
          }
      });

- ##### Optional subduxes?: undefined | __type

  Object mapping slices of the state to sub-upduxes.

  For example, if in plain Redux you would do

      import { combineReducers } from 'redux';
      import todosReducer from './todos';
      import statisticsReducer from './statistics';

      const rootReducer = combineReducers({
          todos: todosReducer,
          stats: statisticsReducer,
      });

  then with Updux you'd do

      import { updux } from 'updux';
      import todos from './todos';
      import statistics from './statistics';

      const rootUpdux = updux({
          subduxes: {
              todos, statistics
          }
      });

### UpduxDispatch

UpduxDispatch: Dispatch & Dictionary <Function>

- Defined in types.ts:27

### UpduxMiddleware

UpduxMiddleware<S>: function

- Defined in types.ts:192

#### Type parameters

- #### S

#### Type declaration

- - (api: UpduxMiddlewareAPI <S>): function

  - #### Parameters

    - ##### api: UpduxMiddlewareAPI <S>

    #### Returns function

    - - (next: UpduxDispatch ): function

      - #### Parameters

        - ##### next: UpduxDispatch

        #### Returns function

        - - (action: Action ): any

          - #### Parameters

            - ##### action: Action

            #### Returns any

### Upreducer

Upreducer<S>: function

- Defined in types.ts:184

#### Type parameters

- #### S

#### Type declaration

- - (action: Action ): function

  - #### Parameters

    - ##### action: Action

    #### Returns function

    - - (state: S): S

      - #### Parameters

        - ##### state: S

        #### Returns S

## Functions

### Const MiddlewareFor

- MiddlewareFor(type: any, mw: Middleware): Middleware

- - Defined in buildMiddleware/index.ts:6

  #### Parameters

  - ##### type: any

  - ##### mw: Middleware

  #### Returns Middleware

### actionCreator

- actionCreator<T, P>(type: T, transform: function): ActionCreator <T, P>
- actionCreator<T>(type: T, transform: never): ActionCreator <T, undefined>
- actionCreator<T>(type: T, transform: null): ActionCreator <T, null>

- - Defined in buildActions/index.ts:4

  #### Type parameters

  - #### T: string

  - #### P: any

  #### Parameters

  - ##### type: T

  - ##### transform: function

    - - (...args: any[]): P

      - #### Parameters

        - ##### Rest ...args: any[]

        #### Returns P

  #### Returns ActionCreator <T, P>

- - Defined in buildActions/index.ts:5

  #### Type parameters

  - #### T: string

  #### Parameters

  - ##### type: T

  - ##### transform: never

  #### Returns ActionCreator <T, undefined>

- - Defined in buildActions/index.ts:6

  #### Type parameters

  - #### T: string

  #### Parameters

  - ##### type: T

  - ##### transform: null

  #### Returns ActionCreator <T, null>

### actionFor

- actionFor(type: string): ActionCreator

- - Defined in buildActions/index.ts:22

  #### Parameters

  - ##### type: string

  #### Returns ActionCreator

### buildActions

- buildActions(generators?: Dictionary < ActionPayloadGenerator >, actionNames?: string[], subActions?: ActionPair []): Dictionary < ActionCreator >

- - Defined in buildActions/index.ts:35

  #### Parameters

  - ##### Default value generators: Dictionary < ActionPayloadGenerator > = {}

  - ##### Default value actionNames: string[] = []

  - ##### Default value subActions: ActionPair [] = []

  #### Returns Dictionary < ActionCreator >

### buildCreateStore

- buildCreateStore<S>(reducer: Reducer<S>, initial: S, middleware: Middleware, actions: Dictionary < ActionCreator >): (Anonymous function)

- - Defined in buildCreateStore/index.ts:9

  #### Type parameters

  - #### S

  #### Parameters

  - ##### reducer: Reducer<S>

  - ##### initial: S

  - ##### middleware: Middleware

  - ##### actions: Dictionary < ActionCreator >

  #### Returns (Anonymous function)

### buildInitial

- buildInitial<S>(initial: S, subduxes?: Dictionary <undefined>): S
- buildInitial<S>(initial?: Partial<S>, subduxes?: Partial<S>): S extends object ? S : never

- - Defined in buildInitial/index.ts:4

  #### Type parameters

  - #### S: number | string | boolean

  #### Parameters

  - ##### initial: S

  - ##### Optional subduxes: Dictionary <undefined>

  #### Returns S

- - Defined in buildInitial/index.ts:5

  #### Type parameters

  - #### S: object

  #### Parameters

  - ##### Optional initial: Partial<S>

  - ##### Optional subduxes: Partial<S>

  #### Returns S extends object ? S : never

### buildMiddleware

- buildMiddleware<S>(effects?: Dictionary < UpduxMiddleware <S>>, actions?: Dictionary < ActionCreator >, subduxes?: any): UpduxMiddleware <S>

- - Defined in buildMiddleware/index.ts:22

  #### Type parameters

  - #### S

  #### Parameters

  - ##### Default value effects: Dictionary < UpduxMiddleware <S>> = {}

  - ##### Default value actions: Dictionary < ActionCreator > = {}

  - ##### Default value subduxes: any = {}

  #### Returns UpduxMiddleware <S>

### buildMutations

- buildMutations(mutations?: Dictionary < Mutation | Object>, subduxes?: object): Dictionary<function>

- - Defined in buildMutations/index.ts:14

  #### Parameters

  - ##### Default value mutations: Dictionary < Mutation | Object> = {}

  - ##### Default value subduxes: object = {}

  #### Returns Dictionary<function>

### buildUpreducer

- buildUpreducer<S>(initial: S, mutations: Dictionary < Mutation <S>>): Upreducer <S>

- - Defined in buildUpreducer/index.ts:5

  #### Type parameters

  - #### S

  #### Parameters

  - ##### initial: S

  - ##### mutations: Dictionary < Mutation <S>>

  #### Returns Upreducer <S>

### Const composeMutations

- composeMutations(mutations: Mutation []): function

- - Defined in buildMutations/index.ts:5

  #### Parameters

  - ##### mutations: Mutation []

  #### Returns function

  - - (payload: A["payload"], action: A): function

    - #### Parameters

      - ##### payload: A["payload"]

      - ##### action: A

      #### Returns function

      - - (state: S): S

        - #### Parameters

          - ##### state: S

          #### Returns S

### sliceMw

- sliceMw(slice: string, mw: Middleware): Middleware

- - Defined in buildMiddleware/index.ts:14

  #### Parameters

  - ##### slice: string

  - ##### mw: Middleware

  #### Returns Middleware

Generated using TypeDoc