@laserware/stasis
    Preparing search index...

    Interface Slice<State, CaseReducers, Name, ReducerPath, Selectors>

    The return value of createSlice

    interface Slice<
        State = any,
        CaseReducers extends SliceCaseReducers<State> = SliceCaseReducers<State>,
        Name extends string = string,
        ReducerPath extends string = Name,
        Selectors extends SliceSelectors<State> = SliceSelectors<State>,
    > {
        actions: CaseReducerActions<CaseReducers, Name>;
        caseReducers: SliceDefinedCaseReducers<CaseReducers>;
        getInitialState: () => State;
        name: Name;
        reducer: Reducer<State>;
        reducerPath: ReducerPath;
        get selectors(): {
            [K in string
            | number
            | symbol]: SliceDefinedSelectors<
                State,
                Selectors,
                { [K in string]: State },
            >[K]
        };
        getSelectors(): {
            [K in string
            | number
            | symbol]: SliceDefinedSelectors<State, Selectors, State>[K]
        };
        getSelectors<RootState>(
            selectState: (rootState: RootState) => State,
        ): {
            [K in string | number | symbol]: SliceDefinedSelectors<
                State,
                Selectors,
                RootState,
            >[K]
        };
        injectInto<NewReducerPath extends string = ReducerPath>(
            this: this,
            injectable: {
                inject: (
                    slice: { reducer: Reducer; reducerPath: string },
                    config?: InjectConfig,
                ) => void;
            },
            config?: InjectIntoConfig<NewReducerPath>,
        ): InjectedSlice<State, CaseReducers, Name, NewReducerPath, Selectors>;
        selectSlice(state: { [K in string]: State }): State;
    }

    Type Parameters

    Index

    Properties

    Action creators for the types of actions that are handled by the slice reducer.

    caseReducers: SliceDefinedCaseReducers<CaseReducers>

    The individual case reducer functions that were passed in the reducers parameter. This enables reuse and testing if they were defined inline when calling createSlice.

    getInitialState: () => State

    Provides access to the initial state value given to the slice. If a lazy state initializer was provided, it will be called and a fresh value returned.

    name: Name

    The slice name.

    reducer: Reducer<State>

    The slice's reducer.

    reducerPath: ReducerPath

    The slice reducer path.

    Accessors

    • get selectors(): {
          [K in string
          | number
          | symbol]: SliceDefinedSelectors<
              State,
              Selectors,
              { [K in string]: State },
          >[K]
      }

      Selectors that assume the slice's state is rootState[slice.reducerPath] (which is usually the case)

      Equivalent to slice.getSelectors((state: RootState) => state[slice.reducerPath]).

      Returns {
          [K in string | number | symbol]: SliceDefinedSelectors<
              State,
              Selectors,
              { [K in string]: State },
          >[K]
      }

    Methods

    • Get localised slice selectors (expects to be called with just the slice's state as the first parameter)

      Returns {
          [K in string | number | symbol]: SliceDefinedSelectors<
              State,
              Selectors,
              State,
          >[K]
      }

    • Get globalised slice selectors (selectState callback is expected to receive first parameter and return slice state)

      Type Parameters

      • RootState

      Parameters

      Returns {
          [K in string | number | symbol]: SliceDefinedSelectors<
              State,
              Selectors,
              RootState,
          >[K]
      }

    • Inject slice into provided reducer (return value from combineSlices), and return injected slice.

      Type Parameters

      Parameters

      • this: this
      • injectable: {
            inject: (
                slice: { reducer: Reducer; reducerPath: string },
                config?: InjectConfig,
            ) => void;
        }
      • Optionalconfig: InjectIntoConfig<NewReducerPath>

      Returns InjectedSlice<State, CaseReducers, Name, NewReducerPath, Selectors>

    • Select the slice state, using the slice's current reducerPath.

      Will throw an error if slice is not found.

      Parameters

      • state: { [K in string]: State }

      Returns State