Add suspend and resume methods.

This commit is contained in:
Michael Teeuw 2016-05-11 13:49:40 +02:00
parent 405a81c8f0
commit c4f3009bb5
2 changed files with 29 additions and 1 deletions

View File

@ -110,6 +110,20 @@ var Module = Class.extend({
Log.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload); Log.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload);
}, },
/* suspend()
* This method is called when a module is hidden.
*/
suspend: function() {
Log.log(this.name + " is suspend.");
},
/* resume()
* This method is called when a module is shown.
*/
resume: function() {
Log.log(this.name + " is resumed.");
},
/********************************************* /*********************************************
* The methods below don"t need subclassing. * * The methods below don"t need subclassing. *
*********************************************/ *********************************************/
@ -291,7 +305,13 @@ var Module = Class.extend({
* argument callback function - Called when the animation is done. * argument callback function - Called when the animation is done.
*/ */
hide: function(speed, callback) { hide: function(speed, callback) {
MM.hideModule(this, speed, callback); callback = callback || function() {};
var self = this;
MM.hideModule(self, speed, function() {
self.suspend();
callback();
});
}, },
/* showModule(module, speed, callback) /* showModule(module, speed, callback)
@ -301,6 +321,7 @@ var Module = Class.extend({
* argument callback function - Called when the animation is done. * argument callback function - Called when the animation is done.
*/ */
show: function(speed, callback) { show: function(speed, callback) {
this.resume();
MM.showModule(this, speed, callback); MM.showModule(this, speed, callback);
} }
}); });

View File

@ -208,6 +208,13 @@ socketNotificationReceived: function(notification, payload) {
}, },
```` ````
####`suspend()`
When a module is hidden (using the `module.hide()` method), the `suspend()` method will be called. By subclassing this method you can perform tasks like halting the update timers.
####`resume()`
When a module will be shown after it was previously hidden (using the `module.show()` method), the `resume()` method will be called. By subclassing this method you can perform tasks restarting the update timers.
### Module instance methods ### Module instance methods
Each module instance has some handy methods which can be helpfull building your module. Each module instance has some handy methods which can be helpfull building your module.