Watup, could you pick up this thing for me NEARBY?
HOME
NEARBY
After 20 metres
After 10 metres
After 5 metres
Destination
HOME
NEARBY
After 20 metres
After 10 metres
After 5 metres
Destination
You have to check out this RESTAURANT on your trip abroad!
HOTEL
RESTAURANT
After 20 metres
After 10 metres
After 100 metres
After 28 metres
After 5 metres
After 50 metres
After 23 metres
After 5 metres
After 10 metres
After 20 metres
HOTEL
RESTAURANT
After 20 metres
After 10 metres
After 100 metres
After 28 metres
After 5 metres
After 50 metres
After 23 metres
After 5 metres
After 10 metres
After 20 metres
HOTEL
RESTAURANT
After 20 metres
After 10 metres
After 100 metres
After 28 metres
After 5 metres
After 50 metres
After 23 metres
After 5 metres
After 10 metres
After 20 metres
IMPERATIVE
DECLARATIVE
Declarative state and side effects management for popular JavaScript frameworks
Cerebral
Stateful Component method
Mobx Action
Redux Thunk/Reducer
Cerebral Signal
APPLICATION LOGIC
webpackbin - 2016
collaboration - 2017
DEBUGGER
CODE
PROJECT
http://localhost
CODE EDITOR
BROWSER
COMPANION
3 files
store/sequences.js
store/actions.js
store/factories.js
10 files
pages/index.js
store/connection/actions.js
store/connection/reducer.js
store/user/actions.js
store/user/reducer.js
store/api/actions.js
pages/Sandbox/index.js
store/entities/sandboxes/actions/index.js
store/entities/sandboxes/reducer.js
store/entities/sandboxes/entity.js
21 state changes
9 side effects
sandboxChanged
export const loadSandbox = factories.withLoadApp([
set(state`editor.error`, null),
when(state`editor.sandboxes.${props`id`}`),
{
true: [
set(state`editor.currentId`, props`id`),
set(props`sandbox`, state`editor.sandboxes.${props`id`}`),
actions.setCurrentModuleShortid,
actions.setMainModuleShortid,
actions.setInitialTab,
actions.setUrlOptions,
actions.setWorkspace,
],
false: [
set(state`editor.isLoading`, true),
set(state`editor.notFound`, false),
set(state`editor.changedModuleShortids`, []),
actions.getSandbox,
{
success: [
set(state`editor.sandboxes.${props`sandbox.id`}`, props`sandbox`),
set(state`editor.currentId`, props`sandbox.id`),
actions.setCurrentModuleShortid,
actions.setMainModuleShortid,
actions.setInitialTab,
actions.setUrlOptions,
actions.setWorkspace,
ensurePackageJSON,
],
notFound: set(state`editor.notFound`, true),
error: set(state`editor.error`, props`error.message`),
},
],
},
set(state`editor.isLoading`, false),
]);
3 files
store/sequences.js
store/actions.js
store/factories.js
10 files
pages/index.js
store/connection/actions.js
store/connection/reducer.js
store/user/actions.js
store/user/reducer.js
store/api/actions.js
pages/Sandbox/index.js
store/entities/sandboxes/actions/index.js
store/entities/sandboxes/reducer.js
store/entities/sandboxes/entity.js
21 state changes
9 side effects
sandboxChanged
export const loadSandbox = withLoadApp([
set(state`editor.error`, null),
when(state`editor.sandboxes.${props`id`}`),
{
true: [
set(state`editor.currentId`, props`id`),
set(props`sandbox`, state`editor.sandboxes.${props`id`}`),
actions.setCurrentModuleShortid,
actions.setMainModuleShortid,
actions.setInitialTab,
actions.setUrlOptions,
actions.setWorkspace,
],
false: [
set(state`editor.isLoading`, true),
set(state`editor.notFound`, false),
set(state`editor.changedModuleShortids`, []),
actions.getSandbox,
{
success: [
set(state`editor.sandboxes.${props`sandbox.id`}`, props`sandbox`),
set(state`editor.currentId`, props`sandbox.id`),
actions.setCurrentModuleShortid,
actions.setMainModuleShortid,
actions.setInitialTab,
actions.setUrlOptions,
actions.setWorkspace,
ensurePackageJSON,
],
notFound: set(state`editor.notFound`, true),
error: set(state`editor.error`, props`error.message`),
},
],
},
set(state`editor.isLoading`, false),
]);
export const loadSandbox = withLoadApp([
...
]);
export const loadSandbox = withLoadApp([
set(state`editor.error`, null),
when(state`editor.sandboxes.${props`id`}`),
{
true: [
set(state`editor.currentId`, props`id`),
set(props`sandbox`, state`editor.sandboxes.${props`id`}`),
actions.setCurrentModuleShortid,
actions.setMainModuleShortid,
actions.setInitialTab,
actions.setUrlOptions,
actions.setWorkspace,
],
false: [
set(state`editor.isLoading`, true),
set(state`editor.notFound`, false),
set(state`editor.changedModuleShortids`, []),
actions.getSandbox,
{
success: [
set(state`editor.sandboxes.${props`sandbox.id`}`, props`sandbox`),
set(state`editor.currentId`, props`sandbox.id`),
actions.setCurrentModuleShortid,
actions.setMainModuleShortid,
actions.setInitialTab,
actions.setUrlOptions,
actions.setWorkspace,
ensurePackageJSON,
],
notFound: set(state`editor.notFound`, true),
error: set(state`editor.error`, props`error.message`),
},
],
},
set(state`editor.isLoading`, false),
]);
set(state`editor.error`, null),
export const loadSandbox = withLoadApp([
set(state`editor.error`, null),
when(state`editor.sandboxes.${props`id`}`),
{
true: [
set(state`editor.currentId`, props`id`),
set(props`sandbox`, state`editor.sandboxes.${props`id`}`),
actions.setCurrentModuleShortid,
actions.setMainModuleShortid,
actions.setInitialTab,
actions.setUrlOptions,
actions.setWorkspace,
],
false: [
set(state`editor.isLoading`, true),
set(state`editor.notFound`, false),
set(state`editor.changedModuleShortids`, []),
actions.getSandbox,
{
success: [
set(state`editor.sandboxes.${props`sandbox.id`}`, props`sandbox`),
set(state`editor.currentId`, props`sandbox.id`),
actions.setCurrentModuleShortid,
actions.setMainModuleShortid,
actions.setInitialTab,
actions.setUrlOptions,
actions.setWorkspace,
ensurePackageJSON,
],
notFound: set(state`editor.notFound`, true),
error: set(state`editor.error`, props`error.message`),
},
],
},
set(state`editor.isLoading`, false),
]);
when(state`editor.sandboxes.${props`id`}`),
{
true: [
...
],
false: [
...
],
},
export const loadSandbox = withLoadApp([
set(state`editor.error`, null),
when(state`editor.sandboxes.${props`id`}`),
{
true: [
set(state`editor.currentId`, props`id`),
set(props`sandbox`, state`editor.sandboxes.${props`id`}`),
actions.setCurrentModuleShortid,
actions.setMainModuleShortid,
actions.setInitialTab,
actions.setUrlOptions,
actions.setWorkspace,
],
false: [
set(state`editor.isLoading`, true),
set(state`editor.notFound`, false),
set(state`editor.changedModuleShortids`, []),
actions.getSandbox,
{
success: [
set(state`editor.sandboxes.${props`sandbox.id`}`, props`sandbox`),
set(state`editor.currentId`, props`sandbox.id`),
actions.setCurrentModuleShortid,
actions.setMainModuleShortid,
actions.setInitialTab,
actions.setUrlOptions,
actions.setWorkspace,
ensurePackageJSON,
],
notFound: set(state`editor.notFound`, true),
error: set(state`editor.error`, props`error.message`),
},
],
},
set(state`editor.isLoading`, false),
]);
set(state`editor.currentId`, props`id`),
set(props`sandbox`, state`editor.sandboxes.${props`id`}`),
actions.setCurrentModuleShortid,
actions.setMainModuleShortid,
actions.setInitialTab,
actions.setUrlOptions,
actions.setWorkspace,
export const loadSandbox = withLoadApp([
set(state`editor.error`, null),
when(state`editor.sandboxes.${props`id`}`),
{
true: [
set(state`editor.currentId`, props`id`),
set(props`sandbox`, state`editor.sandboxes.${props`id`}`),
actions.setCurrentModuleShortid,
actions.setMainModuleShortid,
actions.setInitialTab,
actions.setUrlOptions,
actions.setWorkspace,
],
false: [
set(state`editor.isLoading`, true),
set(state`editor.notFound`, false),
set(state`editor.changedModuleShortids`, []),
actions.getSandbox,
{
success: [
set(state`editor.sandboxes.${props`sandbox.id`}`, props`sandbox`),
set(state`editor.currentId`, props`sandbox.id`),
actions.setCurrentModuleShortid,
actions.setMainModuleShortid,
actions.setInitialTab,
actions.setUrlOptions,
actions.setWorkspace,
ensurePackageJSON,
],
notFound: set(state`editor.notFound`, true),
error: set(state`editor.error`, props`error.message`),
},
],
},
set(state`editor.isLoading`, false),
]);
actions.getSandbox,
{
success: [
...
],
notFound: set(state`editor.notFound`, true),
error: set(state`editor.error`, props`error.message`),
},
Lessons learned refactoring Codesandbox.io from Redux to Cerebral
https://medium.com/@christianalfoni/lessons-learned-refactoring-codesandbox-io-from-redux-to-cerebral-40e9a5646281
FACEBOOK FLUX
ACTION
STORE
DISPATCHER
VIEW
STORE
STORE
STORE
STORE
ACTION
DISPATCHER
VIEW
FACEBOOK FLUX
BAOBAB
VIEW
ELM
DB INSIDE OUT
tree.set([‘text’], ‘newText’)
{
method: ‘set’,
path: [‘text’],
value: ‘newText’
}
May 9th
2015
May 8th
2015
July 2nd
2015
Immutable-store gets signals and a time machine
Cerebral first commit
Live React: Hot Reloading with Time Travel at react-europe 2015
https://www.youtube.com/watch?v=Txpw4wU4BCU&t=127s
https://www.youtube.com/watch?v=xsSnOQynTHs
[
]
CEREBRAL
FUNCTION-TREE
ADDRESSBAR
https://localhost
67 CONTRIBUTORS
www.cerebraljs.com
tree.set([‘text’], ‘newText’)
{
method: ‘set’,
path: [‘text’],
value: ‘newText’
}
dispatch({� type: ‘UPDATE_TEXT’,
payload: ‘newText’�})
{� type: ‘UPDATE_TEXT’,
payload: ‘newText’�}
(state, action) => {
return newState
}
DISPATCH
TRANSACTION
MUTATION
TREE
tree.set([‘text’], ‘newText’)
{
method: ‘set’,
path: [‘text’],
value: ‘newText’
}
dispatch({� type: ‘UPDATE_TEXT’,
payload: ‘newText’�})
{� type: ‘UPDATE_TEXT’,
payload: ‘newText’�}
(state, action) => {
return newState
}
DISPATCH
TRANSACTION
MUTATION
TREE