-
Notifications
You must be signed in to change notification settings - Fork 194
/
index.js
46 lines (38 loc) · 895 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var merge = require('react/lib/merge')
var MainStore = require('../stores/main')
var Db = require('../db')
module.exports = {
run: run
}
function run(options, done) {
if (arguments.length === 1) {
done = options
options = {}
}
options = merge({
plugins: [],
children: require('./demo-data'),
}, options)
if (!options.PL) {
options.PL = require('../pl/mem')
}
var pl = new options.PL()
var db = new Db(pl)
db.init(function (err) {
if (err) return console.error('Failed to start db', err);
if (options.children) {
db.dump(db.root, options.children)
}
var plugins = []
options.plugins.forEach((plugin) => {
if (plugin.store) plugins.push(plugin.store)
})
var store = new MainStore({
plugins: plugins,
pl: db
})
window.store = store
window.actions = store.actions
done(store)
})
}