Shenglian / -WORK_TIP

工作上小技巧
4 stars 1 forks source link

[js] wait at least #149

Open Shenglian opened 5 years ago

Shenglian commented 5 years ago

In order to solve flickering Spinner


function waitAtLeast(time: number, promise: any) {
const promiseTimeout = new Promise(resolve => setTimeout(resolve, time))
const promiseCombined = Promise.all([promise, promiseTimeout])

return promiseCombined.then(values => values[0]) }

Shenglian commented 5 years ago

Article

Shenglian commented 5 years ago

Demo