我正在创建的 JavaScript API 具有以下结构:
var engine = new Engine({
engineName: "TestEngine",
engineHost: "localhost"
});
// I don't want to proceed to the next line until Engine is fully loaded
// But the following part of the API is immediately called before the above is loaded
engine.startCar(
"car_name",
"car_id"
);
"Engine"实例需要几秒钟来加载(1-2秒)。因此,在此期间不应调用engine.startCar
。
我该如何对构造函数(new Engine()
)进行内部更改,以使其在完全加载之前不返回实例?
engine.startCar
作为一个延续。 - Matt Burland