mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-03 17:45:12 +08:00
Summary: At times, ReactPackage needs to get information from the ReactInstanceManager, e.g. to get the DevSupportManager for debugging purpose. This allows passing down the instance manager to create the native modules, in addition to just ReactApplicationContext. It is then up to the Package to use it or not. To use this, you must make your package class extends ReactInstancePackage, instead of just implementing ReactPackage interface. Reviewed By: mmmulani Differential Revision: D4641997 fbshipit-source-id: 497c4408a7d2b773c49f08bff7c1bf8f9d372edb
35 lines
1.2 KiB
Java
35 lines
1.2 KiB
Java
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
package com.facebook.react;
|
|
|
|
import java.util.List;
|
|
|
|
import com.facebook.react.bridge.NativeModule;
|
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
|
|
/**
|
|
* A simple wrapper for ReactPackage to make it aware of its {@link ReactInstanceManager}
|
|
* when creating native modules. This is useful when the package needs to ask
|
|
* the instance manager for more information, like {@link DevSupportManager}.
|
|
*
|
|
* TODO(t11394819): Consolidate this with LazyReactPackage
|
|
*/
|
|
public abstract class ReactInstancePackage implements ReactPackage {
|
|
|
|
public abstract List<NativeModule> createNativeModules(
|
|
ReactApplicationContext reactContext,
|
|
ReactInstanceManager reactInstanceManager);
|
|
|
|
@Override
|
|
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
throw new RuntimeException("ReactInstancePackage must be passed in the ReactInstanceManager.");
|
|
}
|
|
}
|