Skip to content

Instantly share code, notes, and snippets.

@mig82
Last active September 10, 2021 16:46
Show Gist options
  • Save mig82/3caa3180d4fb73351496b4184fd21c19 to your computer and use it in GitHub Desktop.
Save mig82/3caa3180d4fb73351496b4184fd21c19 to your computer and use it in GitHub Desktop.
A sample form controller for Vis Quantum projects
define(["util/doBar", "util/getQux"], function(doBar, getQux){
const PI = 3.1416
let count = 0
function doFoo(){ //This is a static function.
//TODO
}
return{
async doStuff(){
//doFoo() Call static functions
//doBar() //Leverage require modules —e.g. modules/require/util/doBar.js
},
async init(){
//Stuff you only want done once the first time the screen is visited.
},
async preShow(){
//Move stuff out of sight if you want to then animate back in.
},
async postShow(){
//Call services to populate screen.
//Animate stuff back into sight.
},
async onHide(){
//Make sure you destroy/empty large variables that won't be needed anymore.
},
async onOrientationChange(){
//Resize and resposition stuff.
},
async onBreakpointChange(){
//For responsive web, tell your components about the change in screen width.
},
async onNavigate(){
//Wire it all together.
this.view.init = this.init
this.view.preShow = this.preShow
this.view.postShow = this.postShow
this.view.onHide = this.onHide
this.view.onOrientationChange = this.onOrientationChange
this.view.onBreakpointChange = this.onBreakpointChange
},
async onDestroy(){
//Free up or reset any large variables.
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment