FunA (res=& gt; {
If (res)
FunIf ({()=& gt; {
The console. The log (' in the if the callback);
})
The else
FunElse (()=& gt; {
The console. The log (' in the else callback ');
})
});
I am such a turn (assuming the promise with the same style) :
FunA (). Then (res=& gt; {
If (res)
Return funIf ();//if the branch of Promise
The else
Return funElse ();//the else branch Promise
}). Then (()=& gt; {
//here is how do I know which branch to come over?
The console. The log (' in the if or else? ');
});
I want to ask is, I in the back then, how can you know, this is the inside of the front then which branch?
Or, I should not use this model?
CodePudding user response:
FunA (). Then (res=& gt; {
If (res)
Return funIf ();//if the branch of Promise
The else
Return funElse ();//the else branch Promise
}). Then ((previousReturn)=& gt; {//& lt;======
//here is how do I know which branch to come over?
The console. The log (' in the if or else? ', previousReturn);//a then the return value will be the next then get, can be judged according to the
});
CodePudding user response:
Really want to have this kind of demand, the simplest is on your return if or else, the additional definitions or attach a label,