Josh David Miller PRO
startup advisor, speaker, CEO. More than mildly obsessed in seeing founders succeed. I only use my powers for good.
Flux is a UI architecture with a uni-directional data flow.
asks for data, listens for changes
updates if necessary, tells listeners data changed
gets action requests, dispatches to stores
a description of an event
Redux is a predictable state container for JavaScript apps.
{
}
currentAlbum: { ... },
playlist: [ ... ],
currentTrack: { ... },
user: {
email: 'josh@joshdmillercom',
preferences: { ... },
},
( state ) =>
({
});
repeat: state.user.preferences.repeat,
track: state.currentTrack,
{
}
type: 'PLAY_TRACK',
track: 1234,
( state, action ) => {
};
switch ( action.type ) {
}
case 'PLAY_TRACK':
return {
...state,
currentTrack: action.track,
};
default:
return state;
case 'SKIP_TRACK':
return {
...state,
currentTrack: /* ... */,
};
// ...
function dispatch ( action ) {
this.state = functions.reduce( function ( state, fn ) {
return fn( state, action );
}, this.state );
this.listeners.forEach( fn => fn() );
}asks for the data it needs
description of what happened
immutable POJO
reduce a new state
Everything is a Component
( state ) => ui
State is Immutable
Data Flows Down
Events Bubble Up
( state, action ) => state
By Josh David Miller
startup advisor, speaker, CEO. More than mildly obsessed in seeing founders succeed. I only use my powers for good.