Skip to content

Instantly share code, notes, and snippets.

@kattak
Last active July 25, 2017 20:41
Show Gist options
  • Save kattak/bf249d6c7e9e8da301d0bea8f1759bc6 to your computer and use it in GitHub Desktop.
Save kattak/bf249d6c7e9e8da301d0bea8f1759bc6 to your computer and use it in GitHub Desktop.
Notes from watching Redux creator's videos on egghead.io https://egghead.io/lessons/javascript-redux-the-single-immutable-state-tree

Two principles of Redux: (1) the single immutable state tree (2) the state tree is redundant

1. The Single Immutable State Tree

  • Represent the whole state of app as a single JS object
  • All changes and mutations to state are explicit
  • State or state tree: everything that changes in your app is contained in this object

2. The State Tree is Redundant (?)

  • Dispatch an action: change the state
  • Rec: use strings because they are "surorizable" (serializable?)
  • The only way to change a state tree is to dispatch an action

1. Pure and Impure Functions

Pure

  • return value depends soley on value of args
  • does not overwrite args
  • returns a new object

Impure:

  • Might have side effects
  • Operate on the DOM
  • Overwrite given args

NB: Why important? Some of the functions you write have to be pure.

Big Idea: UI/View layer most predictable when described as a pure function of the application's state

  • State mutations in app needs to be describe as a pure function
  • Takes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment