Assign resolve function from Promise to a variable
问题 There's a snippet of code that I cannot seem to understand. There's a function that is declare empty at first: let dCredentials = (credentials: any) => {} Then this variable is later reasignned in a function later called: return new Promise((resolve, _) => (dispatchCredentials = resolve)) What does the second code do? Does it return anything after someone uses .then in the promise? 回答1: If you get a reference to the resolve function to outside the promise, then you can resolve it at any point