-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
packages/react-native-web/src/exports/TurboModuleRegistry/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright (c) Nicolas Gallagher. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* | ||
*/ | ||
|
||
const NativeModules = require('../NativeModules'); | ||
|
||
import invariant from 'invariant'; | ||
|
||
function requireModule(name) { | ||
const legacyModule = NativeModules[name]; | ||
if (legacyModule != null) { | ||
return legacyModule; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
function get(name) { | ||
return requireModule(name); | ||
} | ||
|
||
function getEnforcing(name) { | ||
const module = requireModule(name); | ||
invariant( | ||
module != null, | ||
`TurboModuleRegistry.getEnforcing(...): '${name}' could not be found. ` + | ||
'Verify that a module by this name is registered in the native binary.', | ||
); | ||
return module; | ||
} | ||
|
||
var TurboModuleRegistry = { | ||
get, | ||
getEnforcing, | ||
}; | ||
|
||
export default TurboModuleRegistry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters