Fixed race condition in RCTModuleData.methodQueue

Summary:
public
The implementation of the `methodQueue` lazy initializer in `RCTModuleData` could result in the queue being set twice, because calling `methodQueue` for a module that hasn't been instantiated would call `RCTModuleData.instance` to create the module, which itself calls `methodQueue`.

It's not clear if this was causing a bug, but it may be related to an occasional bug where the `RCTViewManager.methodQueue` returns nil.

Reviewed By: majak

Differential Revision: D2783320

fb-gh-sync-id: 9194da0fd7392f63825da1f5c450363dd300b635
This commit is contained in:
Nick Lockwood
2016-01-04 06:23:51 -08:00
committed by facebook-github-bot-9
parent 46609cf7f0
commit 64edddadcc
3 changed files with 70 additions and 48 deletions

View File

@@ -94,7 +94,7 @@ RCT_EXTERN void RCTRegisterModule(Class); \
* }
*
* If you don't want to specify the queue yourself, but you need to use it
* inside your class (e.g. if you have internal methods that need to disaptch
* inside your class (e.g. if you have internal methods that need to dispatch
* onto that queue), you can just add `@synthesize methodQueue = _methodQueue;`
* and the bridge will populate the methodQueue property for you automatically
* when it initializes the module.