undefinedfix
Sign in

Which specific scenarios of the project will the promise object be used in

Maverick edited in Fri, 02 Sep 2022

The promise object is usually used in the specific scenarios of the project, which is rarely used in the actual writing. Of course, I don't write many projects myself

5 Replies
thabouti
commented on Sat, 03 Sep 2022

When asynchronous, when there are more interfaces.

exp
commented on Sat, 03 Sep 2022

The new features of ES6 are used everywhere, including but not limited to the Ajax request tool such as fetch / Axios (all return promise to avoid nested callbacks). Even if you need it, you can use it in most scenarios that need to be asynchronous. For example, it is very simple to rewrite the common setTimeout to promise version

https://github.com/rxliuli/rx...

If you know a little about ES7 async / await, it will be more comfortable to use

Async function fn () {/ / sending request modifies data... //Wait 1000 ms await wait (1000) / / return to the data list page... }

ydczr
commented on Sat, 03 Sep 2022

Promise is used to solve the problem of callback hell, so it can be used when you need to perform callback operations. The common method is to use promise to process Ajax requests.

user3295859
commented on Sat, 03 Sep 2022

In addition to sending requests, it is rarely used

WINJUDIQQ
commented on Sat, 03 Sep 2022

When asynchronous operation has dependent sequence, use promise to solve the problem of callback

lock This question has been locked and the reply function has been disabled.