mirror of
https://github.com/aelve/guide.git
synced 2024-11-23 04:07:14 +03:00
2968979823
+ handle data + view data + read state on client side
18 lines
514 B
JavaScript
18 lines
514 B
JavaScript
// common shared js
|
|
import '../common/shared.js';
|
|
// polyfills
|
|
require('es6-promise').polyfill();
|
|
|
|
export const initClient = function (client) {
|
|
// window.__puxInitialState is the JSON serialized state injected after
|
|
// rendering on the server (src/Server.purs).
|
|
const initialState = client.readState(window.__puxInitialState);
|
|
|
|
const app = client.main(window.location.pathname)(window.__puxLastState || initialState)();
|
|
|
|
app.state.subscribe(function (state) {
|
|
window.__puxLastState = state;
|
|
});
|
|
|
|
}
|