次のようにラッパー、モックサンプルを作成しています
var car = function() {
}
car.prototype.method1 = function() {
this.method2();
}
car.protoptype.method2 = function(callback) {
var request = foo() //call to async method
request.onsucces = function() {
this.method3();
});
}
car.protoptype.method3 = function(callback) {
this.method4(); //not found
}
car.protoptype.method4 = function(callback) {
//code
}
//呼び出し元
var vehicle = new Car;
vehicle.method1()
私の問題は、メソッド 4 が呼び出されないことです。onsuccess コールバックにネストされているため、「this」はメソッド 4 のオブジェクトに適用されませんか?