Skip to content

Cxx TurboModules > Add example to return a JS function from Cxx to JS#41385

Closed
christophpurrer wants to merge 1 commit into
facebook:mainfrom
christophpurrer:export-D50473063
Closed

Cxx TurboModules > Add example to return a JS function from Cxx to JS#41385
christophpurrer wants to merge 1 commit into
facebook:mainfrom
christophpurrer:export-D50473063

Conversation

@christophpurrer
Copy link
Copy Markdown
Contributor

Summary:
Changelog: Internal

Adding a Cxx TM example which adds a listener and returns a subscription to remove that listener from the TM.

You should be able to use this with React Hooks - https://legacy.reactjs.org/docs/hooks-reference.html

E.g.

useEffect(() => {
  const subscription =  NativeCxxModuleExample.setValueCallbackWithSubscription(
          callbackValue => // use it
        );
  return subscription;
});

Differential Revision: D50473063

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 9, 2023
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D50473063

@analysis-bot
Copy link
Copy Markdown

analysis-bot commented Nov 9, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 17,654,490 +12,616
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 21,034,023 +12,292
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 19945ad
Branch: main

…facebook#41385)

Summary:

Changelog: Internal

Adding a Cxx TM example which adds a listener and returns a subscription to remove that listener from the TM.

You should be able to use this with React Hooks - https://legacy.reactjs.org/docs/hooks-reference.html

E.g.

```
useEffect(() => {
  const subscription =  NativeCxxModuleExample.setValueCallbackWithSubscription(
          callbackValue => // use it
        );
  return subscription;
});
```

Reviewed By: shwanton

Differential Revision: D50473063
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D50473063

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Nov 9, 2023
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in 9320174.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants