Support emitting typed RCTDeviceEmitter events

Summary:
This enables to code-gen base C++ types for custom exported JS types from a RN TM spec - which have been previously excluded from code-gen as these aren't used in any function.

The only work around so far was to ‘register’ a random function using the custom type which should be used for RCTDeviceEventEmitter events

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D56685903

fbshipit-source-id: add9ca40018b91c9fca98609ba3d1f85d3affec1
This commit is contained in:
Christoph Purrer
2024-04-30 11:16:57 -07:00
committed by Facebook GitHub Bot
parent cfbee0b7ec
commit c96c893374
9 changed files with 147 additions and 12 deletions
@@ -116,6 +116,17 @@ template <>
struct Bridging<MenuItem>
: NativeCxxModuleExampleCxxMenuItemBridging<MenuItem> {};
#pragma mark - RCTDeviceEventEmitter events
using CustomDeviceEvent = NativeCxxModuleExampleCxxCustomDeviceEvent<
std::string,
int32_t,
std::optional<float>>;
template <>
struct Bridging<CustomDeviceEvent>
: NativeCxxModuleExampleCxxCustomDeviceEventBridging<CustomDeviceEvent> {};
#pragma mark - implementation
class NativeCxxModuleExample
: public NativeCxxModuleExampleCxxSpec<NativeCxxModuleExample> {
@@ -185,7 +196,7 @@ class NativeCxxModuleExample
void setMenu(jsi::Runtime& rt, MenuItem menuItem);
void emitCustomDeviceEvent(jsi::Runtime& rt, jsi::String eventName);
void emitCustomDeviceEvent(jsi::Runtime& rt, const std::string& eventName);
void voidFuncThrows(jsi::Runtime& rt);