DeLorean.js
DeLorean is a tiny Flux pattern implementation.
- Unidirectional data flow, it makes your app logic simpler than MVC,
- Automatically listens data changes and keeps your data updated,
- Makes data more consistent in your whole application,
- Too easy to use with React.js; just add a mixin,
- Too easy to use with Flight.js; see the example,
- It's framework agnostic, completely. There's no view framework dependency.
- Too small, just 4K gzipped.
Overview
Install
You can install DeLorean with Bower:
bower install delorean
You can also install by NPM to use with Browserify (recommended)
npm install delorean.js
Usage
Hipster way:
var Flux = require('delorean.js').Flux;
Old-skool way:
<script src="//rawgit.com/f/delorean/master/dist/delorean.min.js"></script>
<script>
var Flux = DeLorean.Flux;
</script>
Overview
var Store = Flux.createStore({
data: null,
setData: function (data) {
this.data = data;
this.emit('change');
},
actions: {
'incoming-data': 'setData'
}
});
var store = new Store();
var Dispatcher = Flux.createDispatcher({
setData: function (data) {
this.dispatch('incoming-data', data);
},
getStores: function () {
return {increment: store};
}
});
var Actions = {
setData: function (data) {
Dispatcher.setData(data);
}
};
store.onChange(function () {
document.getElementById('result').innerText = store.store.data;
});
document.getElementById('dataChanger').onClick = function () {
Actions.setData(Math.random());
};
Docs
Basic Concepts
Or you can visit documents page.
Running the TodoMVC example
There is a simple TodoMVC example working with DeLorean.js
cd examples/todomvc
grunt
open index.html
Name
The flux capacitor was the core component of Doctor Emmett Brown's time traveling DeLorean time machine
License
MIT License