-
Notifications
You must be signed in to change notification settings - Fork 0
/
server-entry.js
52 lines (44 loc) · 1.47 KB
/
server-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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// import { app, router, store } from './app';
// export default context => {
// console.log(context);
// router.push(context.url);
// return new Promise((resolve, reject) => {
// // set server-side router's location
// // wait until router has resolved possible async components and hooks
// router.onReady(() => {
// const matchedComponents = router.getMatchedComponents();
// // console.log(matchedComponents);
// // no matched routes, reject with 404
// if (!matchedComponents.length) {
// return reject({ code: 404 });
// }
// matchedComponents.map(component => {
// if (component.asyncData) {
// return component.asyncData(store, router.currentRoute).then(() => {
// context.initialState = store.state;
// console.log(context.initialState.postsModule.posts);
// resolve(app);
// });
// }
// resolve(app);
// });
// // the Promise should resolve to the app instance so it can be rendered
// }, reject);
// });
// // return app;
// };
import { createApp } from './app';
export default context => {
const { app, router, store } = createApp();
// console.log(context);
return new Promise((resolve, reject) => {
router.push(context.url);
router.onReady(() => {
context.rendered = () => {
context.state = store.state;
console.log(context.state);
};
resolve(app);
}, reject);
});
};