Advertisement
k2s

Dojo Application Object

k2s
Oct 12th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Main application instance
  3.  */
  4. define(["dojo/_base/declare", "dojo/_base/config"], function(declare, dojoConfig) {
  5.     "use strict";
  6.  
  7.     var AppSingletonClass = declare(null, {
  8.         config: {},
  9.  
  10.         constructor: function () {
  11.             this.config = dojoConfig.appConfig || {};
  12.             console.debug("app config:", this.config);
  13.         },
  14.  
  15.         run: function () {
  16.             console.debug("app starting");
  17.             this._initUI();
  18.         // ....
  19.             console.debug("app started");
  20.         },
  21.  
  22.         _initUI: function () {
  23.         // ....
  24.         },
  25.  
  26.         doRefreshData: function(){
  27.             require(["dojo/request"], function(request){
  28.                 request.post("app/hello", {
  29.             // .....
  30.                 });
  31.             }
  32.         },
  33.  
  34.         doHello: function () {
  35.             window.alert("hello");
  36.         }
  37.     });
  38.  
  39.     AppSingletonClass.getSingleton = function () {
  40.         if (AppSingletonClass._singletonInstance === undefined || AppSingletonClass._singletonInstance === null) {
  41.             AppSingletonClass._singletonInstance = new AppSingletonClass();
  42.         }
  43.         return AppSingletonClass._singletonInstance;
  44.     };
  45.  
  46.     return AppSingletonClass.getSingleton();
  47. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement