Hi,
I am starting WebOS dev and I have a doubt on where should I start and stop my listeners ? I am reading this book but I couldn't find a clear explanation about this. In the sample the author set the listeners in the setup function but I wonder why? isn't a better idea to set them in activate function and stop them in deactivate function as suggested by the template's comments?
In case I am wrong what kind of events should and shouldn't put in setup and activate functions?
When exactly setup, activate, deactivate, cleanup functions are called?
StoryViewAssistant.prototype.setup = function() {
//HERE, OK?
this.nextStoryHandler = this.nextStory.bindAsEventListener(this);
this.previousStoryHandler = this.previousStory.bindAsEventListener(this);
this.controller.listen("nextStory", Mojo.Event.tap, this.nextStoryHandler);
this.controller.listen("previousStory", Mojo.Event.tap,this.previousStoryHandler);
/* add event handlers to listen to events from widgets */
};
StoryViewAssistant.prototype.activate = function(event) {
//HERE?
/* put in event handlers here that should only be in effect when this scene is active. For example, key handlers that are observing the document */
};
StoryViewAssistant.prototype.deactivate = function(event) {
//HERE?
/* remove any event handlers you added in activate and do any other cleanup that should happen before this scene is popped or another scene is pushed on top */
};
StoryViewAssistant.prototype.cleanup = function(event) {
//HERE, OK?
this.controller.stopListening("nextStore", Mojo.Event.tap, this.nextStoryHandler);
};
Thanks in advance