Add C++ Turbo Module Event Emitter example (#44810)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44810

Adds an example how to use the `EventEmitter` on a (C++) Turbo Module

## Changelog:

[General] [Added] - Add C++ Turbo Module Event Emitter example

Reviewed By: javache

Differential Revision: D57473949

fbshipit-source-id: 1a8d17fb83af4220ef12379e0102b5b2e233ed45
This commit is contained in:
Christoph Purrer
2024-06-11 21:12:33 -07:00
committed by Facebook GitHub Bot
parent 872d5d3c5e
commit 6a3a305628
3 changed files with 43 additions and 1 deletions
@@ -9,6 +9,7 @@
*/
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
import type {EventEmitter} from 'react-native/Libraries/Types/CodegenTypes';
import {TurboModuleRegistry} from 'react-native';
@@ -76,6 +77,10 @@ export type CustomDeviceEvent = {
};
export interface Spec extends TurboModule {
+onPress: EventEmitter<void>;
+onClick: EventEmitter<string>;
+onChange: EventEmitter<ObjectStruct>;
+onSubmit: EventEmitter<ObjectStruct[]>;
+getArray: (arg: Array<ObjectStruct | null>) => Array<ObjectStruct | null>;
+getBool: (arg: boolean) => boolean;
+getConstants: () => ConstantsStruct;