budibase/packages/builder/src/builderStore/index.js

30 lines
685 B
JavaScript
Raw Normal View History

2019-07-13 11:35:57 +02:00
import {createPackage} from "./createPackage";
import getStore from "./store";
2019-07-31 09:09:04 +02:00
export const store = getStore();
2019-07-13 11:35:57 +02:00
export const createNewPackage = () =>
2019-07-31 09:09:04 +02:00
createPackage(packageInfo, store);
2019-07-13 11:35:57 +02:00
export const initialise = async () => {
try {
2019-07-31 09:09:04 +02:00
setupRouter(store);
await store.initialise();
2019-07-13 11:35:57 +02:00
} catch(err) {
console.log(err);
}
}
const setupRouter = (writable) => {
const pushState = history.pushState;
history.pushState = () => {
pushState.apply(history, arguments);
//fireEvents('pushState', arguments);
writable.initialise();
}
window.addEventListener('hashchange',()=>{
writable.initialise();
})
}