Preferred way of dealing with both architectures #50
-
Hi, Methods written in There's also a warning in the RN docs: Let's assume I have the following spec interface: export interface Spec extends TurboModule {
getConstants: () => {};
add(a: number, b: number): Promise<number>;
getSDKVersion(): string;
} Since, Should we use (...)
// new arch
- (NSString *)getSDKVersion {
return @"test";
}
// old arch
RCT_REMAP_METHOD(getSDKVersion, getSDKVersionAsync:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
resolve(@("test"));
} type TurboModule = {
add: (a: number, b: number) => Promise<number>;
getSDKVersion: () => string;
};
type NativeModule = {
add: (a: number, b: number) => Promise<number>;
getSDKVersion: () => Promise<string>;
}; Thanks and have a great day! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @mateioprea, thanks for your question. We created some examples to help handling both architectures at the same time: this repo contains a branch with TurboModules and Fabric Components that can work on both architectures. At the moment, we still have to use the For your specific question, I see two alternatives:
What do you think? |
Beta Was this translation helpful? Give feedback.
Hi @mateioprea, thanks for your question.
We created some examples to help handling both architectures at the same time: this repo contains a branch with TurboModules and Fabric Components that can work on both architectures.
At the moment, we still have to use the
RCT_EXPORT_METHOD
macros to export a function from a TurboModule. TheRCT_REMAP_METHOD
is just the same as theRCT_EXPORT_METHOD
: additionally, it allows you to rename the method.For your specific question, I see two alternatives: