I'm trying to solve a callback problem with js Classes. I need if any function is performed to return data.
class MoveSection {
constructor(name){
this.name = name;
//Some code
}
nextMove{
//Some Code
onLeave:function(args, callback){
console.log(args);
if(typeof callback == "function")
callback();
}
//Somecode
}
prevMove{
//Some Code
onLeave:function(args, callback){
console.log(args);
if(typeof callback == "function")
callback();
}
//Somecode
}
}
const section = new MoveSection("My Name");
section.onLeave(){
console.log("Section moving in:" this.name);
}
This is dont work? How create this callback in 2 function OnMove