Liliana Kastilio
Technical Services Architect at @snyksec #typescript ♥ ❯ Organiser of @devs_london ❯ Polyglot ❯ dnb ♥ ❯ aerialist ❯ she/her #javascript #nodejs #python #django
(without React 😱)
⇒ complex data flow
⇒ multiple components relying on the same data
⇒ tiny simple 2kb library
⇒ one single source of truth
⇒ state is read-only
⇒ changes are made with pure functions
⇒ 1 store per application
⇒ contains all the up to date data needed by all the components
⇒ state can only be changed with Actions
⇒ Given the same input produce the same output
⇒ no side effects
⇒ relies on no external state
⇒ is a JavaScript tree object
⇒ usually a key/value map
import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
import thunk from 'redux-thunk';
import '../scss/styles.scss';
import { notesBoard } from './notesBoard';
import { notesBoardReducer } from './reducers/notesBoard.reducer';
document.addEventListener('DOMContentLoaded', function (event) {
notesBoard();
const store = createStore(
notesBoardReducer,
compose(
applyMiddleware(thunk),
),
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
);
});
⇒ plain objects
⇒ any code that wants to update the store must dispatch an action
⇒ a reducing function
⇒ takes in an old state and outputs a new state
By Liliana Kastilio
Technical Services Architect at @snyksec #typescript ♥ ❯ Organiser of @devs_london ❯ Polyglot ❯ dnb ♥ ❯ aerialist ❯ she/her #javascript #nodejs #python #django