Skip to content

Commit

Permalink
rename preStartup to postConfig for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
green3g committed Feb 1, 2017
1 parent 5c6b537 commit 5c65783
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
41 changes: 25 additions & 16 deletions viewer/js/viewer/_ControllerBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ define([
declare, lang, Deferred
) {
return declare(null, {

/**
* A method run before anything else, can be inherited by mixins to
* load and process the config sync or async
Expand All @@ -22,9 +23,32 @@ define([
* @return {undefined | Deferred} If the operation is async it should return
* a deferred, otherwise it should return the value of `this.inherited(arguments)`
*/
preStartup: function () {
postConfig: function () {
return this.inherited(arguments);
},
/**
* Start the application mixin chain, once the
* startupDeferred is resolved
* @return {undefined}
*/
startup: function () {

// cache the inherited
var inherited = this.getInherited(arguments);

// load config and process it
this.startupDeferred = this.executeSync([
this.loadConfig,
this.postConfig
]);

// wait for any loading to complete
this.startupDeferred.then(lang.hitch(this, function () {

// start up the mixin chain
inherited.apply(this);
}));
},
/**
* executes an array of asynchronous methods synchronously
* @param {Array<function>} methods The array of functions to execute
Expand All @@ -51,21 +75,6 @@ define([
}
return deferred;

},
startup: function () {

var inherited = this.getInherited(arguments);
this.executeSync([
this.loadConfig,
this.preStartup
]).then(lang.hitch(this, function () {
console.log(this);

// start up the mixin chain
inherited.apply(this);
}));


},

//centralized error handler
Expand Down
4 changes: 2 additions & 2 deletions viewer/js/viewer/_LayoutMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ define([
}
},
collapseButtons: {},
preStartup: function () {
postConfig: function () {
this.layoutDeferred = new Deferred();
return this.inherited(arguments);
},
Expand All @@ -77,7 +77,7 @@ define([
this.addTitles();
this.detectTouchDevices();
this.initPanes();

this.mapDeferred.then(lang.hitch(this, 'createPanes'));

// resolve the layout deferred
Expand Down
2 changes: 1 addition & 1 deletion viewer/js/viewer/_MapMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ define([

return declare(null, {

preStartup: function () {
postConfig: function () {
this.mapDeferred = new Deferred();
return this.inherited(arguments);
},
Expand Down
2 changes: 1 addition & 1 deletion viewer/js/viewer/_WidgetsMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ define([

widgets: {},
widgetTypes: ['titlePane', 'contentPane', 'floating', 'domNode', 'invisible', 'map', 'layer', 'layout', 'loading'],
preStartup: function (wait) {
postConfig: function (wait) {

var waitDeferred;
if (wait) {
Expand Down

0 comments on commit 5c65783

Please sign in to comment.