react-native-macos/ReactCommon
Ruslan Shestopalyuk 407fb5c238 Implement ability to emit device events from C++ TurboModules
Summary:
[Changelog][Internal]

This adds a method, `emitDeviceEvent` to the C++ API of TurboModules, which allows to make calls to JS's `RCTDeviceEventEmitter.emit` from a C++ TurboModules.

This is a very common pattern, specifically for the VR apps, but not only for them - e.g. Desktop fork also has a [custom implementation for this](https://www.internalfb.com/code/fbsource/third-party/microsoft-fork-of-react-native/react-native-utils/RCTEventEmitter.cpp).

Note that my original intent was to actually backport the latter, however there are some complications with wiring things in a robust way, without exposing too much stuff and relying on singletons or folly::dynamic.

So I ended up adding it to the TurboModule API itself and use the scheduler/JSI facilities instead.

This approach is arguably well self-contained, uses high level APIs, and shouldn't be abusable much.

Since I was trying to avoid usage of folly::dynamic in this case, I used a kind of "value factory" pattern instead in order to send the arguments to the JS thread in a thread safe way (see [the discussion here](https://fb.workplace.com/groups/rn.fabric/permalink/1398711453593610/)).

Reviewed By: christophpurrer

Differential Revision: D43466326

fbshipit-source-id: a3cb8359d08a46421559edd0f854772863cb5c39
2023-02-21 15:15:31 -08:00
..
butter Use std::shared_mutex instead of folly::shared_mutex 2023-02-16 06:25:26 -08:00
callinvoker ReactCommon > Minor BUCK clean-up (#36134) 2023-02-13 10:45:14 -08:00
cxxreact Fully remove usage of timed runtime 2023-02-09 06:16:26 -08:00
hermes Address New Architecture performance regressions by properly setting NDEBUG (#36172) 2023-02-16 06:03:01 -08:00
jsc Address New Architecture performance regressions by properly setting NDEBUG (#36172) 2023-02-16 06:03:01 -08:00
jsengineinstance The life-changing magic of clang-tidying up 2020-02-04 11:09:30 -08:00
jserrorhandler Revert D42369492: Add basic tests for JsErrorHandler 2023-01-05 13:25:50 -08:00
jsi Only intercept JSIExceptions when constructing JSError 2023-01-22 00:25:49 -08:00
jsiexecutor Restore Dynamic framework with Hermes in the Old Architecture 2023-01-30 04:25:26 -08:00
jsinspector Enable C++17 for cxxreact and jsiexecutor/inspector and ... (#35435) 2022-11-23 18:48:47 -08:00
libraries/fbcore/src/test/java/com/facebook/powermock Explicitly set language to JAVA where it is missing [xplat] (round 1) 2022-07-06 09:07:07 -07:00
logger Update .podspec license information (#35245) 2022-11-07 09:52:52 -08:00
react Implement ability to emit device events from C++ TurboModules 2023-02-21 15:15:31 -08:00
reactperflogger Update .podspec license information (#35245) 2022-11-07 09:52:52 -08:00
runtimeexecutor Update .podspec license information (#35245) 2022-11-07 09:52:52 -08:00
yoga Remove config null check 2023-02-14 09:42:43 -08:00
React-Fabric.podspec Break Circular Dependency between React-Codegen and React-Fabric (#36210) 2023-02-20 11:50:10 -08:00
React-rncore.podspec Break Circular Dependency between React-Codegen and React-Fabric (#36210) 2023-02-20 11:50:10 -08:00
ReactCommon.podspec Update podspecs with the right search paths 2023-02-20 11:50:10 -08:00