-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbrowser.js
43 lines (33 loc) · 1.12 KB
/
browser.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
const pull = require('pull-stream')
const combine = require('depject')
const { entry } = require('inu')
const start = require('inu-engine')
const prioritize = require('depject-priority')
const configModule = require('./config')
const appModules = require('./lib/app')
const coreModules = require('./modules')
// TODO this should be a depject module,
// but first need to refactor this inu
// code to work as such, using something
// like: https://github.com/depject/depject/issues/26
module.exports = startBrowser
function startBrowser () {
const sockets = combine(prioritize(
configModule,
appModules(),
coreModules
))
const cssRender = sockets.css.render[0]
const htmlUpdate = sockets.html.update[0]
const styles = document.createElement('style')
document.head.appendChild(styles)
console.log('sockets', sockets)
cssRender(styles)
const store = entry(sockets)
const { views, dispatch } = start(store)
// HACK inject dispatch
sockets.inu.dispatch.push(dispatch)
const main = document.createElement('div')
document.body.appendChild(main)
pull(views(), pull.drain(htmlUpdate.bind(null, main)))
}