Namespace Unity.AppUI.Redux
Classes
ActionCreator
An action creator.
ActionCreator<TPayload>
An action creator with a payload.
ReducerSwitchBuilder<TState>
The Reducer Switch Builder is used to build a reducer switch statement via method chaining. You must have created Action Creators for each action type you want to handle prior to using this.
Slice
A Slice is a collection of reducers and actions for a specific part of the application state.
SliceReducerSwitchBuilder<TState>
The Slice Reducer Switch Builder is used to build a reducer switch statement via method chaining. This builder does not require you to create Action Creators. It will automatically create them for you.
Slice<TState>
A Slice is a collection of reducers and actions for a specific domain. It is a convenient way to bundle them together for use in a Redux store.
Store
A store holds the whole state tree of your application. The only way to change the state inside it is to dispatch an action on it. Your application should only have a single store in a Redux app. As your app grows, instead of adding stores, you split the root reducer into smaller reducers independently operating on the different parts of the state tree.
The store has the following responsibilities:- Holds application state
- Allows access to state via GetState<TState>(string)
- Allows state to be updated via Dispatch(Action)
- Registers listeners via Subscribe<TState>(string, Action<TState>)
- Handles unregistering of listeners via the function returned by Subscribe<TState>(string, Action<TState>)
Here are some important principles you should understand about Reducers:
- Reducers are the only way to update the state.
- Reducers are pure functions that take the previous state and an action, and return the next state.
- Reducers must be pure functions. They should not mutate the state, perform side effects like API calls or routing transitions, or call non-pure functions.
- Reducers must not do asynchronous logic.
- Reducers must not call other Reducer.
- Reducers must not call Subscribe<TState>(string, Action<TState>).
- Reducers must not call GetState<TState>(string)
- Reducers must not call Dispatch(Action)
Delegates
ActionMatcher
A predicate function that takes an action and returns true if the action should be handled by the reducer.
CaseReducer<TState>
A function that takes the current state and an action, and returns a new state.
CaseReducer<T, TState>
A function that takes the current state and an action, and returns a new state.
Reducer
A function that takes the current state and an action, and returns a new state.
Unsubscriber
A function obtained from Subscribe<TState>(string, Action<TState>) that can be called to unsubscribe the listener.