Files: 224ba37003f0c72d7a782bb20e5f96d4bfb61b5b / browser.js
1088 bytesRaw
1 | const pull = require('pull-stream') |
2 | const combine = require('depject') |
3 | const { entry } = require('inu') |
4 | const start = require('inu-engine') |
5 | |
6 | const configModule = require('./config') |
7 | const appModules = require('./lib/app') |
8 | const coreModules = require('./modules') |
9 | |
10 | // TODO this should be a depject module, |
11 | // but first need to refactor this inu |
12 | // code to work as such, using something |
13 | // like: https://github.com/depject/depject/issues/26 |
14 | |
15 | module.exports = startBrowser |
16 | |
17 | function startBrowser () { |
18 | const sockets = combine( |
19 | configModule, |
20 | appModules(), |
21 | coreModules |
22 | ) |
23 | |
24 | const cssRender = sockets.css.render[0] |
25 | const htmlUpdate = sockets.html.update[0] |
26 | |
27 | const styles = document.createElement('style') |
28 | document.head.appendChild(styles) |
29 | console.log('sockets', sockets) |
30 | cssRender(styles) |
31 | |
32 | const store = entry(sockets) |
33 | const { views, dispatch } = start(store) |
34 | |
35 | // HACK inject dispatch |
36 | sockets.inu.dispatch.push(dispatch) |
37 | |
38 | const main = document.createElement('div') |
39 | document.body.appendChild(main) |
40 | |
41 | pull(views(), pull.drain(htmlUpdate.bind(null, main))) |
42 | } |
43 |
Built with git-ssb-web