In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail about the relationship between resolved and fulfilled in Promise. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Fulfilled's understanding:
I know that the Promise constructor accepts a function as an argument, and the function can take two arguments (also methods, provided by the js engine) resolve,reject, meaning "solve" and "reject, discard", respectively. Literally, it is easy to understand that these two methods are used to transform the state of Promise from pending to fulfilled and rejected.
pending- > resolve method-> fulfilled
pending- > reject method-> rejected
from this can see my understanding is that those who say what resolved is fulfilled state, from the English grammar resolved is the past tense of resolve, that is to say, "solved", that means that the solution is successful, so according to the above process is also the state of fulfilled, then resolved and fulfilled are in the same state.
But feels untenable from another point of view, because if it is solved, must it be successful? Think a little ('.')
Some paragraphs of the promise chapter fulfilled
clearly knows from this discourse that the resolved referred to by Ruan Shen is also my trouble. what he said here can clearly see that resolved temporarily refers to the fulfilled state. if it is not this article, what if in the actual process, resolved does not necessarily mean that the state has changed to the fulfilled state, but there will be other possibilities, such as changing to the rejected state?!
Next, callback functions such as catch,then return the Promise of resolve.
, then please allow me once again to quote the original sentence from Ruan God's promise.all:
In the above code, promises is an array of six Promise instances, and the callback function following the Promise.all method will be called only if the state of all six instances changes to fulfilled, or one of them becomes rejected.
so only if the stateful state changes to fulfilled can the callback function after all be executed!
The picture above in is actually described as follows: when the promise in all has its own catch method, when the promise becomes rejected, it triggers the catch method of its own promise, but not the catch method of promise that follows outside the all method.
The reason for is simple: after the callback of the sub-catch method, it returns another promise in resolved state, so the final accepted children are all in resolved state.
This is the end of the article on "what is the relationship between resolved and fulfilled in Promise". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.