"use strict";
const realm = require("realm-js");
class MyChain {
setFoo() {
// I am the first one. And i set this.foo = "foo1"
return "foo1";
}
setBar() {
// I am the second one, and i have "this.foo" at my disposal
// And i set this.bar = "bar1"
return "bar1";
}
justSomethingFunky()
{
// I am the third one, and everyone will wait for me
let self = this;
return new Promise(function(resolve, reject){
// But i will not assign anything
// Just have to resolve myself
return resolve(self.bar)
})
}
setHello()
{
// I am the last to be executed, and i will assign this.hello = "world"
return "world";
}
}
realm.chain(MyChain).then(function(result){
console.log(result);
});