Promise multiple execution order

app.isLogin ()
     // after determining whether the login 
    .then (RES => {
         the this .setData ({ 
          Login: to true 
        }, RES2 => {
           // Clear the temporary integral 
          return app.clearTempScore ()    // Returns Promise 
        }) 
    } ) 
    .then (RES => { 
      the console.log ( ' .then .............. ' ) 
    }) 
    . the catch (ERR => { 
      the console.log (ERR) 
    })

1, setData returned Promise

   Directly performs the second .then (), even if the status is returned app.clearTempScore Pending (normal return Promise, the state is pending, not execute .then ())

   Because setData is an asynchronous request, we do not know when the callback res2, returned Promise (or understood as: has got)

   This case, .then () does not return a direct Promise, equal to not return Promise

app.isLogin ()
     // after determining whether the login 
    .then (RES => { 
        
    }) 
    .then (RES => { 
      the console.log ( ' .then .............. ' ) 
    }) 
    . the catch (ERR => { 
      the console.log (ERR) 
    })

2, a first .then () does not return a direct Promise, execution of the second code sequence .then ()

3, a first .then () has a direct return Promise, the code will wait for the return of the Promise, resolve or reject with the state, and then perform a second .then ()

Guess you like

Origin www.cnblogs.com/qq254980080/p/12043856.html