我正在启动WebOS dev,我怀疑我应该从哪里开始并停止我的听众?我正在读这本书,但我找不到明确的解释.在示例中,作者在设置函数中设置了侦听器,但我想知道为什么?在模板的注释建议中,将它们设置为激活功能并将其停止在停用功能中是不是更好的主意?
万一我错了什么样的事件应该和不应该放在设置和激活功能?
何时完全设置,激活,取消激活,清除功能?
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 …Run Code Online (Sandbox Code Playgroud)