Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doubt] - Async Operations #3

Open
EduFrazao opened this issue Mar 7, 2022 · 1 comment
Open

[Doubt] - Async Operations #3

EduFrazao opened this issue Mar 7, 2022 · 1 comment

Comments

@EduFrazao
Copy link

Hi @barthap . Thank you very mutch for sharing your discoverys.
I'm trying to contribute with a project that you mention in your repo (react-native-quick-sqlite), implementing some async operations, but I have some doubts and problems that I couldn't overcome yeat.

I need to use turbo modules in order to use callinvoker, or I can use it with a regular JSI Non Turbo Module implementation?

@barthap
Copy link
Owner

barthap commented Mar 8, 2022

Yes, Call invoker is essential when doing async operations. You can also see the discussion in #1 for some examples (and more links) on async stuff in JSI

You don't need TurboModules to use call invoker. On iOS, your native module should inherit from RCTBridgeModule, then you can just do:

- (void)setBridge:(RCTBridge *)bridge {
  _bridge = bridge;
  RCTCxxBridge *cxxBridge = (RCTCxxBridge *)self.bridge;
  jsi::Runtime* jsiRuntime = (jsi::Runtime *)cxxBridge.runtime;
  auto callInvoker = bridge.jsCallInvoker;

On Android, it is a bit more complex, you have there a com.facebook.react.turbomodule.core.CallInvokerHolderImpl class, which is a fbjni hybrid class. So you need the fbjni library to unwrap the call invoker on the C++ side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants