Created
July 26, 2016 10:05
-
-
Save nchanged/b0abb7849fdb8417fc1712d9ca0b5c23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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){ | |
// {foo : "foo1", bar : "bar1", hello: "world" } | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment