mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-04 09:27:53 +08:00
don't call OnBatchComplete on specific modules unless we need to
Summary: Don't call OnBatchComplete on NativeModules that have'nt been initialized. Also a follow up to D4479604. This also removes the extra allocation of OnBatchCompleteListener per NativeModule that implements OnBatchCompleteListener. This means NativeModules which implement OnBatchCompleteListener will have to be explicitly initialized or called into before the OnBatchCompleteListener of that NativeModule will be triggered. Reviewed By: javache Differential Revision: D4483682 fbshipit-source-id: 6a9431c82f72d17605d1c1e0ee9194f8d8fc2ddc
This commit is contained in:
committed by
Facebook Github Bot
parent
6a5225fb22
commit
53a7d5822b
@@ -113,18 +113,10 @@ public class NativeModuleRegistryBuilder {
|
||||
}
|
||||
|
||||
public NativeModuleRegistry build() {
|
||||
ArrayList<OnBatchCompleteListener> batchCompleteListenerModules = new ArrayList<>();
|
||||
ArrayList<ModuleHolder> batchCompleteListenerModules = new ArrayList<>();
|
||||
for (Map.Entry<Class<? extends NativeModule>, ModuleHolder> entry : mModules.entrySet()) {
|
||||
Class<? extends NativeModule> type = entry.getKey();
|
||||
if (OnBatchCompleteListener.class.isAssignableFrom(type)) {
|
||||
final ModuleHolder moduleHolder = entry.getValue();
|
||||
batchCompleteListenerModules.add(new OnBatchCompleteListener() {
|
||||
@Override
|
||||
public void onBatchComplete() {
|
||||
OnBatchCompleteListener listener = (OnBatchCompleteListener) moduleHolder.getModule();
|
||||
listener.onBatchComplete();
|
||||
}
|
||||
});
|
||||
if (OnBatchCompleteListener.class.isAssignableFrom(entry.getKey())) {
|
||||
batchCompleteListenerModules.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user