Skip to content

Instantly share code, notes, and snippets.

@ryardley
Last active January 1, 2019 20:30
Show Gist options
  • Save ryardley/091c98112dfdf57ccf83f0a5e2b69164 to your computer and use it in GitHub Desktop.
Save ryardley/091c98112dfdf57ccf83f0a5e2b69164 to your computer and use it in GitHub Desktop.
Complete implementation bridging to C++
// ./ios/ReactBridge/RCTHelloWorld.m
#import "RCTHelloWorld.h"
#import "HWHelloWorld.h"
@implementation RCTHelloWorld{
HWHelloWorld *_cppApi;
}
- (RCTHelloWorld *)init
{
self = [super init];
_cppApi = [HWHelloWorld create];
return self;
}
+ (BOOL)requiresMainQueueSetup
{
return NO;
}
RCT_EXPORT_MODULE();
RCT_REMAP_METHOD(sayHello,
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
NSString *response = [_cppApi getHelloWorld];
resolve(response);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment