WebOS開発を開始していますが、リスナーをどこから開始および停止する必要があるのか疑問がありますか?私はこの本を読んでいますが、これについて明確な説明を見つけることができませんでした。サンプルでは、作者はセットアップ関数でリスナーを設定しましたが、なぜだろうか?テンプレートのコメントで示唆されているように、それらをアクティブ化機能に設定し、非アクティブ化機能で停止することをお勧めしますか?
私が間違っている場合、どのような種類のイベントをセットアップして機能をアクティブ化する必要がありますか?
正確にセットアップ、アクティブ化、非アクティブ化、クリーンアップ機能が呼び出されると?
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);
};