September 2018
Intermediate to advanced
302 pages
7h 17m
English
A union type describes a value that can be one of several types. This is a great fit for our Tasks reducer type:
export type TaskReduxActionType = AddTaskActionType | TasksFetchActionType | TasksFetchCompleteActionType | TasksFetchErrorActionType | TaskFetchActionType | TaskFetchCompleteActionType | TaskFetchErrorActionType;
The union type is created with the | operator. It works just as if it was | was or. One type or another.
We can now use the previous type in the Reducer function:
// src/ Chapter_11/ // Example_3/ src/ features/ tasks/ state/ reducers/ tasksReducer.tsconst tasksReducer = ( state = Immutable.Map<string, any>({ entities: Immutable.List<TaskType>([]), isLoading: false, hasError: false ...
Read now
Unlock full access