-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
misc: Add linked errors examples to the sample apps (#3549)
* Fix native linked errors execution order * fix lint * Add integrations execution order tests * Add jest extended types and linkedErrors order tests * Add changelog * remove empty test * fix native linked errors async calls * fix native async calls ios * fix old arch build * feat: Add linked errors examples to the sample apps * fix sample lint * remove unused header file
- Loading branch information
1 parent
deebf78
commit bc4b9f6
Showing
10 changed files
with
150 additions
and
15 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
17 changes: 17 additions & 0 deletions
17
...-native/android/app/src/main/java/com/samplenewarchitecture/NativePlatformSampleModule.kt
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,17 @@ | ||
package com.samplenewarchitecture | ||
|
||
import com.facebook.fbreact.specs.NativePlatformSampleModuleSpec | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
|
||
class NativePlatformSampleModule(reactContext: ReactApplicationContext) : NativePlatformSampleModuleSpec(reactContext) { | ||
|
||
override fun getName() = NAME | ||
|
||
override fun crashOrString(): String { | ||
throw RuntimeException("JVM Crash in NativePlatformSampleModule.crashOrString()") | ||
} | ||
|
||
companion object { | ||
const val NAME = "NativePlatformSampleModule" | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...es/react-native/android/app/src/main/java/com/samplenewarchitecture/TurboSamplePackage.kt
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,39 @@ | ||
package com.samplenewarchitecture | ||
|
||
import com.facebook.react.TurboReactPackage | ||
import com.facebook.react.bridge.NativeModule | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.module.model.ReactModuleInfo | ||
import com.facebook.react.module.model.ReactModuleInfoProvider | ||
import org.jetbrains.annotations.Nullable | ||
|
||
class TurboSamplePackage : TurboReactPackage() { | ||
@Nullable | ||
override fun getModule( | ||
name: String, | ||
reactApplicationContext: ReactApplicationContext | ||
): NativeModule? { | ||
return if (name == NativePlatformSampleModule.NAME) { | ||
NativePlatformSampleModule(reactApplicationContext) | ||
} else { | ||
null | ||
} | ||
} | ||
|
||
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider { | ||
return ReactModuleInfoProvider { | ||
val moduleInfos: MutableMap<String, ReactModuleInfo> = | ||
HashMap() | ||
moduleInfos[NativePlatformSampleModule.NAME] = ReactModuleInfo( | ||
NativePlatformSampleModule.NAME, | ||
NativePlatformSampleModule.NAME, | ||
false, // canOverrideExistingModule | ||
false, // needsEagerInit | ||
true, // hasConstants | ||
false, // isCxxModule | ||
true // isTurboModule | ||
) | ||
moduleInfos | ||
} | ||
} | ||
} |
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
9 changes: 9 additions & 0 deletions
9
samples/react-native/ios/sampleNewArchitecture/NativePlatformSampleModule.h
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,9 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
#ifdef RCT_NEW_ARCH_ENABLED | ||
#import <AppSpecs/AppSpecs.h> | ||
|
||
@interface NativePlatformSampleModule : NSObject <NativePlatformSampleModuleSpec> | ||
|
||
@end | ||
#endif |
22 changes: 22 additions & 0 deletions
22
samples/react-native/ios/sampleNewArchitecture/NativePlatformSampleModule.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,22 @@ | ||
#import "NativePlatformSampleModule.h" | ||
|
||
#ifdef RCT_NEW_ARCH_ENABLED | ||
|
||
@implementation NativePlatformSampleModule | ||
|
||
RCT_EXPORT_MODULE(); | ||
|
||
// Thanks to this guard, we won't compile this code when we build for the old architecture. | ||
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params { | ||
return std::make_shared<facebook::react::NativePlatformSampleModuleSpecJSI>(params); | ||
} | ||
|
||
- (NSString *)crashOrString { | ||
NSObject * nilObject = NULL; | ||
NSArray * _ = @[nilObject]; | ||
return @"NEVER RETURNED"; | ||
} | ||
|
||
@end | ||
|
||
#endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { TurboModule } from 'react-native'; | ||
import { TurboModuleRegistry } from 'react-native'; | ||
|
||
export interface Spec extends TurboModule { | ||
crashOrString(): string; | ||
} | ||
|
||
export default TurboModuleRegistry.get<Spec>('NativePlatformSampleModule'); |