3
Suppose I had the following method:
this.loadCustomers = function(){
Request.get("php/loadCustomersAction.php", (function(error, data){
if(!error)
this.setCustomers(data);
}).bind(this));
};
where "Request.get" is a method that performs asynchronous calls.
It is possible to imagine that the "this" in
this.setCustomers()
can maintain the same scope as
this.loadCustomers()
without the help of bind when establishing callback and without making the function synchronous? If yes, how could it be done?
I ended up opting for the use of bind, even. It seemed to me the least risky way to work. Thank you!
– Brunno Vianna