Files: bf1c0487e7a3cc6ff42c236b70370491e557e10f / app / sync / start.js
1156 bytesRaw
1 | const nest = require('depnest') |
2 | |
3 | exports.gives = nest({ |
4 | 'app.sync.start': true, |
5 | 'config.sync.load': true // used by patchcore |
6 | }) |
7 | |
8 | exports.needs = nest({ |
9 | 'app.html.app': 'first', |
10 | 'app.page.errors': 'first', |
11 | 'app.sync.goTo': 'first', |
12 | 'app.sync.initialise': 'first', |
13 | 'history.obs.location': 'first', |
14 | 'history.sync.push': 'first', |
15 | 'settings.sync.get': 'first' |
16 | }) |
17 | |
18 | exports.create = function (api) { |
19 | var _config |
20 | return nest({ |
21 | 'app.sync.start': start, |
22 | 'config.sync.load': config |
23 | }) |
24 | |
25 | function start (config, opts = {}) { |
26 | console.log('STARTING Patchbay UI') |
27 | |
28 | _config = config |
29 | localStorage.patchbayConfig = null |
30 | |
31 | const App = api.app.html.app(opts.initialTabs) |
32 | |
33 | api.app.sync.initialise(App, config) |
34 | // runs all the functions in app/sync/initialise |
35 | |
36 | api.history.obs.location()(api.app.sync.goTo) |
37 | |
38 | document.body.appendChild(App) |
39 | return App |
40 | } |
41 | |
42 | function config () { |
43 | console.log('getting called!!!') |
44 | return _config || JSON.parse(localStorage.patchbayConfig) |
45 | // HACK - there's a depject race condition where config.sync.load is being called |
46 | // before app.sync.start is called! |
47 | } |
48 | } |
49 |
Built with git-ssb-web