store refactoring

This commit is contained in:
Géry Debongnie
2019-02-20 14:55:49 +01:00
parent 16dc33cc05
commit 264420a96b
9 changed files with 376 additions and 289 deletions
+12 -4
View File
@@ -10,10 +10,13 @@ import { INotification, RPC, Services, Store } from "./store";
export interface Env extends WEnv {
services: Services;
// helpers
dispatch(action: string, param?: any): void;
// commands
activateMenuItem(menuId: number): void;
addNotification(notif: Partial<INotification>): number;
closeNotification(id: number);
closeNotification(id: number): void;
toggleHomeMenu(): void;
// helpers
rpc: RPC;
// configuration
@@ -33,11 +36,16 @@ export function makeEnv(store: Store, templates: string): Env {
const env: Env = {
qweb,
getID: idGenerator(),
services: store.services,
dispatch: store.dispatch.bind(store),
activateMenuItem: store.activateMenuItem.bind(store),
addNotification: store.addNotification.bind(store),
closeNotification: store.closeNotification.bind(store),
toggleHomeMenu: store.toggleHomeMenu.bind(store),
rpc: store.rpc.bind(store),
debug: false,
isMobile: window.innerWidth <= 768
};