createStore(reducer, initialState, [enhancer])

Redoodle packages a version of createStore that requires initial state. This function is more included for completeness, and lacks some useful features that the Redux core createStore has, such as clean Observables integration and more complete runtime usage checks.

If the lost features are important to you, please do use the version of createStore exposed by Redux.

For more about store enhancers, see the Redux documentation.

Note: Redoodle's Reducer semantics differ very slightly from Redux's in regards to initial State handling. In short, Redoodle Reducer's actually aren't expected to respond to undefined, although this can cause initial integration problems to an existing Redux application. For more, please check out the Initial State Management section.

Example

import { Action, createStore } from "redoodle";

interface AppState {
  foo: string;
}

function reducer(state: AppState, action: Action) {
  return state;
}

const store = createStore<AppState>(reducer, {foo: "initial"});

TypeScript definition

function createStore<S>(reducer: Reducer<S>, initialState: S, enhancer?: StoreEnhancer): Store<S>;
interface StoreEnhancer {
  <S>(next: StoreCreator<S>): StoreCreator<S>;
}

results matching ""

    No results matching ""