move some sideeffect code to makeEnvironment

This commit is contained in:
Géry Debongnie
2019-02-01 10:33:26 +01:00
parent f165142430
commit d2d622b3c3
2 changed files with 8 additions and 10 deletions
+8
View File
@@ -9,6 +9,8 @@ import {
} from "./services/notifications"; } from "./services/notifications";
import { registry, Registry } from "./services/registry"; import { registry, Registry } from "./services/registry";
import { IRouter, Router } from "./services/router"; import { IRouter, Router } from "./services/router";
import { CRM } from "./widgets/crm";
import { Discuss } from "./widgets/discuss";
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Types // Types
@@ -53,12 +55,18 @@ export interface Env extends WEnv {
* this function will actually return the same environment. * this function will actually return the same environment.
*/ */
export const makeEnvironment = memoize(function(): Env { export const makeEnvironment = memoize(function(): Env {
// main application registry
registry.add("action", "discuss", Discuss);
registry.add("action", "crm", CRM);
// services
const qweb = new QWeb(); const qweb = new QWeb();
const router = new Router(); const router = new Router();
const ajax = new Ajax(); const ajax = new Ajax();
const actionManager = new ActionManager(router, registry); const actionManager = new ActionManager(router, registry);
const notifications = new NotificationManager(); const notifications = new NotificationManager();
// demo data
const menus = [ const menus = [
{ title: "Discuss", actionID: 1 }, { title: "Discuss", actionID: 1 },
{ title: "CRM", actionID: 2 } { title: "CRM", actionID: 2 }
-10
View File
@@ -3,16 +3,6 @@
import { debounce } from "./core/utils"; import { debounce } from "./core/utils";
import { makeEnvironment } from "./env"; import { makeEnvironment } from "./env";
import { Root } from "./root"; import { Root } from "./root";
import { registry } from "./services/registry";
import { CRM } from "./widgets/crm";
import { Discuss } from "./widgets/discuss";
//------------------------------------------------------------------------------
// Prepare application registry
//------------------------------------------------------------------------------
registry.add("action", "discuss", Discuss);
registry.add("action", "crm", CRM);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Application bootstrapping // Application bootstrapping