Last active
February 12, 2016 00:07
-
-
Save esnya/1eefe07f8ce78d330216 to your computer and use it in GitHub Desktop.
Promiseコード片
This file contains hidden or 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
let hoge = null; | |
const getHoge = () => hoge | |
? Promise.resolve(hoge) | |
: new Promise((resolve, reject) => { | |
someAsnycWork((data) => { | |
hoge = data; | |
resolve(data); | |
}) | |
}); | |
export const doHoge = () => | |
getHoge() | |
.then((hoge) => (someWorkWithHoge(hoge))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment