Back when I did LUA i used to run dofile("..."); to load other lua files and such. Later to find out that this is a very bad practice and can lead to applications breaks.
Now that I am on my way to developing a WebOs application, i want to make sure I am properly changing scene before i pick up bad programming habit.
At the moment this is what I use:
label2Tap: function(inSender, event) {
Mojo.Controller.stageController.popScene();
Mojo.Controller.stageController.swapScene("LogicAndArithmetic");
},
Which works great to get to my LogicAndArithmetic scene, is this the best practice to do such?
Thanks.
The scene model in the Mojo framework of webOS works like a stack. When the app starts you call
pushSceneto display your main scene. Normally, you then make additionalpushScenecalls to add scenes to the stack on top, and then when you are done with them they are popped, typically when the user performs the ‘back gesture’, bringing back the previous scene. Eventually you will be back at your main scene.The
swapScenecall is equivalent to callingpopSceneand thenpushScenefor a different scene. In your case you are callingpopScenethenswapScene, so that is the equivalent of popping two scenes from the stack and then pushing back one. It probably works because you have only one scene, but if you had more it would not work correctly.BTW, why are you working with Mojo and not Enyo?