You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

39 lines
889 B

priority 1000
snippet class "Adds a class"
class ${1:class_name}{
/**
* this function is run as soon as possible.
* the dom isn't neccessarily loaded / parsed
**/
constructor(){
//Bind this in the following functions to the class
this.domLoaded = this.domLoaded.bind(this);
//check to see if the dom has loaded yet
if(document.readyState == "loading"){
//if the dom hasn't loaded, wait until it is
document.addEventListener("readystatechange",this.domLoaded);
return;
} else {
//if it has, run the domloaded function
this.domLoaded();
}
}
/**
* this function is run as soon as the dom is loaded
**/
domLoaded(){
//make sure we don't run this twice
document.removeEventListener("readystatechange",this.domLoaded);
}
}
new $1();
$0
endsnippet
snippet bind "creates a bind statement"
this.${1:functionName} = this.$1.bind(this);
endsnippet