-
Notifications
You must be signed in to change notification settings - Fork 4
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
5 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
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
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
23 changes: 23 additions & 0 deletions
23
packages/react-native-nitro-modules/cpp/turbomodule/RegisterNativeNitroModules.cpp
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,23 @@ | ||
// | ||
// RegisterNativeNitroModules.cpp | ||
// DoubleConversion | ||
// | ||
// Created by Marc Rousavy on 21.06.24. | ||
// | ||
|
||
#include "RegisterNativeNitroModules.hpp" | ||
#include "NativeNitroModules.hpp" | ||
#include <React-callinvoker/ReactCommon/CallInvoker.h> | ||
#include <ReactCommon/ReactCommon/CxxTurboModuleUtils.h> | ||
|
||
namespace margelo { | ||
|
||
void RegisterNativeNitroModules::registerNativeNitroModules() { | ||
facebook::react::registerCxxModuleToGlobalModuleMap( | ||
std::string(facebook::react::NativeNitroModules::kModuleName), | ||
[&](std::shared_ptr<facebook::react::CallInvoker> jsInvoker) { | ||
return std::make_shared<facebook::react::NativeNitroModules>(jsInvoker); | ||
}); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
packages/react-native-nitro-modules/cpp/turbomodule/RegisterNativeNitroModules.hpp
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,21 @@ | ||
// | ||
// RegisterNativeNitroModules.hpp | ||
// DoubleConversion | ||
// | ||
// Created by Marc Rousavy on 21.06.24. | ||
// | ||
|
||
#pragma once | ||
|
||
namespace margelo { | ||
|
||
class RegisterNativeNitroModules { | ||
public: | ||
/** | ||
Registers the native NitroModules TurboModule into the React Runtime. | ||
This can be called from Swift/Objective-C. | ||
*/ | ||
static void registerNativeNitroModules(); | ||
}; | ||
|
||
} // namespace margelo |
23 changes: 23 additions & 0 deletions
23
packages/react-native-nitro-modules/ios/turbomodule/NitroModuleOnLoad.mm
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,23 @@ | ||
// | ||
// NitroModuleOnLoad.mm | ||
// DoubleConversion | ||
// | ||
// Created by Marc Rousavy on 21.06.24. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "RegisterNativeNitroModules.hpp" | ||
|
||
@interface NitroModulesOnLoad : NSObject | ||
@end | ||
|
||
@implementation NitroModulesOnLoad | ||
|
||
+ (void)load { | ||
// When this Objective-C class is loaded, it registers the CxxTurboModule in the react module system. | ||
// We need Objective-C here because these things do not get compiled out - meaning this will always be | ||
// called when the app starts. | ||
margelo::RegisterNativeNitroModules::registerNativeNitroModules(); | ||
} | ||
|
||
@end |