[ReactNative] Fix bridge event dedupe

This commit is contained in:
Tadeu Zagallo
2015-04-28 08:02:56 -07:00
parent f7276b0ae4
commit 2f4430cf51
3 changed files with 113 additions and 35 deletions

View File

@@ -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