Closed bvjebin closed 7 years ago
Figured it out myself. It is the context binding issue. When I changed the code as given below, things started working.
const bot = {
setFn(what) {
console.log(what);
},
receive(obj) {
return Async((obj) => {
console.log(this, obj);
this.setFn(obj);
return Await(State.find("zzzz"));
})(obj);
}
};
bot.receive({a: 1});
Good work BTW.
The following piece of code is what I am trying.
This snippet when run throws the following exception:
What am I doing wrong? When I printed
this
it just printed empty object. Documentation mentions that thethis
context is preserved. But seems like it is lost.Can anyone help on this?