-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentry.js
38 lines (32 loc) · 1.08 KB
/
entry.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
import { h, render } from 'preact';
import mockNotes from './src/MockNotes'
import { localStore } from './src/KnackInterface'
// for dev only
import 'preact/devtools'
// this holds our rendered root element so we can re-render in response to HMR updates.
let root;
// If this is webpack-dev-server, set up HMR :)
if (module.hot) module.hot.accept('./src/app', init);
// Making our app's initialization a function means it's repeatable.
const init = async () => {
// HMR requires that this be a require()
let App = require('./src/app').default;
var pAppState = new Promise((resolve, reject) =>
localStore.get("appState", resolve))
var pUserSettings = new Promise((resolve, reject) =>
localStore.get("userSettings", resolve))
let values = await Promise.all([pAppState, pUserSettings])
const props = {
app: values[0],
config: {
user: values[1]
}
}
root = render(<App {...props} />, document.body, root);
}
(async () => {
init();
})()
// set mock data for testing
localStore.set("userSettings", { theme: "dark" })
localStore.set("appState", { notes: mockNotes })