Downloads - Introduction To Redux
Downloads - Introduction To Redux
Introduction to Redux
Eric W. Greene
Produced by
Course Overview
Why Redux?
Three Principles of Redux
Essential JavaScript Concepts
Reducer Functions
Working with Stores
Combining Reducers
Integration with React and Asynchronous Operations
Why Redux?
Each action reduces the state to a new predictable state, to which the
application user interface transitions
A state container, known as store, contains the reduction logic
implemented as pure functions as well as the last reduced (current)
state
Three Principles of Redux
Following the pattern of Flux, all data flows through a Redux system in
a unidirectional matter
All changes to the state comes from actions applied to the state, and
all actions are funneled into Redux
No part of the system can ever receive data from two sources
Additionally, the state managed by Redux is the state of the whole
application (with minor exceptions, such as form control entry)
State is Read-Only
Pure functions accept inputs, and using only those inputs produce a
single output
The function produces no side effects
Many pure functions can be composed together to process different
parts of the state tree
Definition of Redux
While Redux and Flux share similar concepts and principles, there are
some differences
Flux differentiates between the dispatcher and store, this is because
Flux supports multiple stores
Redux limits the application to one store which means the store and
dispatcher can be combined into one dispatcher-store
This dispatcher-store is created by Redux's createStore function
Development Environment
Object.assign
Immutable Array Functions
Function Parameter Default Values
Arrow Functions
Destructuring, Spread Operator, and Rest Operator
Fetch & Promises
ES2015 Modules
Essential JavaScript Concepts
Stores are the container for applying the action to the state using the
reducer function, and they contain the current state
Created with the createStore function
The first parameter is the reducer function
The second parameter is an optional initial state, if this is not provided
the default state initialized by the reducer function will be used on the
first run-through
Store Initialization
The state tree for an application can grow quickly especially when
considering the first principle of Redux which is the entire state of the
application is stored in one object
Writing a single reducer function for the whole state tree results in a
long, bloated and difficult to maintain function
Combining Reducers
Redux works great with React, but Redux is not limited to only working
React
Nevertheless, the React/Redux combination is so popular there are
special libraries for tying the two together and there are lots of
resources online which explore this common combination of libraries
Asynchronous programming introduces additional complexities to
managing state
Integration with React