taiki-t's diary

きぎょうにっき, React Native, Rails そして雑多な記録: The world is waiting for you to give it the meaning.

JS

おーい磯野〜 callback使ってる関数をPromiseでラップしてasync/awaitで書こうぜ〜

JS

例1 const sleep = (ms) => { return new Promise(resolve => setTimeout(resolve, ms)); } const something = async () => { await sleep(100) doSomething() } 例2 // クラスの中 getCurrentPosition(options) { return new Promise((resolve, reject) => …