Javascript 异步反应本机
问题:异步代码导致整个源代码遵循异步 示例: 以下是承诺处理的方法Javascript 异步反应本机,javascript,react-native,asynchronous,async-await,Javascript,React Native,Asynchronous,Async Await,问题:异步代码导致整个源代码遵循异步 示例: 以下是承诺处理的方法 。然后((接受)=>{},((拒绝)=>{}) aync函数(_promise){await WriteConfiguration()} .then((\u onAccept)=>{u variableDefinedInParentScope=\u onAccept} 据我所知,第三个变量是无用的,因为我从未遇到任何返回,因为promise正在解析需要时间,在任何解析返回未定义的变量之前调用该变量 本地反应 在react n
- 。然后((接受)=>{},((拒绝)=>{})
- aync函数(_promise){await WriteConfiguration()}
- .then((\u onAccept)=>{u variableDefinedInParentScope=\u onAccept}
我想将值从asyncrous返回到syncrouns代码。没有任何异步链。使用
await
及
例如:
mainFunction(){
//will wait for asyncroFunction to finish!!
await asyncroFunction()
}
async asyncroFunction(){
}
async
mainFunction(){
//will wait for asyncroFunction to finish!!
await asyncroFunction()
}
async asyncroFunction(){
}