mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-06 09:13:27 +08:00
[ReactNative] Fix bridge event dedupe
This commit is contained in:
@@ -312,12 +312,20 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError)
|
||||
|
||||
- (void)executeBlockOnJavaScriptQueue:(dispatch_block_t)block
|
||||
{
|
||||
/**
|
||||
* Always dispatch async, ensure there are no sync calls on the JS thread
|
||||
* otherwise timers can cause a deadlock
|
||||
*/
|
||||
[self performSelector:@selector(_runBlock:)
|
||||
onThread:_javaScriptThread withObject:block waitUntilDone:NO];
|
||||
if ([NSThread currentThread] != _javaScriptThread) {
|
||||
[self performSelector:@selector(executeBlockOnJavaScriptQueue:)
|
||||
onThread:_javaScriptThread withObject:block waitUntilDone:NO];
|
||||
} else {
|
||||
block();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)executeAsyncBlockOnJavaScriptQueue:(dispatch_block_t)block
|
||||
{
|
||||
[self performSelector:@selector(executeBlockOnJavaScriptQueue:)
|
||||
onThread:_javaScriptThread
|
||||
withObject:block
|
||||
waitUntilDone:NO];
|
||||
}
|
||||
|
||||
- (void)_runBlock:(dispatch_block_t)block
|
||||
|
||||
Reference in New Issue
Block a user