Transparently syncs your cerebral model with falcor's cache, intelligently caching client data.
Whenver a change is fired by falcor, cererbral-falcor
diffs falcor's cache with your cererbral model's current state. It calculates the difference, patching the changed data to cerebral. This happens in the background, allowing your components to synchronosly bind to cerebral and update the UI.
Note: falcor --> cerebral
data synchronization is unidirectional, meaning updates to the falcor cache are pushed to cerebral, but not vice-versa. All changes to falcor data are through the exposed falcor API (get, set, call).
Falcor's data is namespaced in your model to prevent overwriting cerebral only data. The defalut namespace for retreiving falcor data is falcor: { falcor: {} }
.
Basic Todo Demo: https://github.com/bfitch/cerebral-falcor-todos
npm install cerebral-falcor-module
// main.js
import FalcorModule from 'cerebral-falcor-module';
controller.register({
falcor: FalcorModule({
model: model // source defaults to: '/model.json',
})
});
const model = Model({
falcor: {} // can also define a custom name
});
service
:const getTodosLength = ({output, services}) => {
services.falcor.get(['todosLength']).
then(response => output(response.json)).
catch(response => output.error);
}
({state}) => {
state.get(['falcor', 'todos']);
}
get(path)
call(functionPath, args, refPaths, thisPaths)
set
{}
falcor-expand-cache
package, which makes the diff and patch strategy possible. Also for redux-falcor
for the general approach.