Skip to main content

foundation-redux.slice

Home > @genesislcap/foundation-redux > Slice

Slice interface

Represents a Redux slice with actions and selectors.

Signature:

export interface Slice<State = any> 

Remarks

A slice contains the reducer, actions, and selectors for a specific domain of your application state.

Example

const userSlice: Slice = {
name: 'user',
reducer: userReducer,
actions: { setUser, logout },
selectors: { getUser, isLoggedIn }
};

Properties

Property

Modifiers

Type

Description

actions

Record<string, (payload: any) => Action>

Action creators for this slice

name

string

The unique name of the slice

reducer

Reducer<State, Action>

The Redux reducer function for this slice

selectors

Record<string, (...args: any[]) => any>

Selector functions for this slice