Add GraphNode example for Cxx TMs (#41766)

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

Changelog: [Internal]

Adds a simple example showing a recursive node, stored inside a collection in a Cxx TM.

Currently we can't auto-generate [the necessary C++ Types](https://reactnative.dev/docs/next/the-new-architecture/cxx-custom-types#struct-generator) - but we can add it later if this scenarios becomes really common.

Reviewed By: rshest

Differential Revision: D51783974

fbshipit-source-id: 7352db1a354cd7da32febc650f7cc5e10dd16d2d
This commit is contained in:
Christoph Purrer
2023-12-04 04:19:47 -08:00
committed by Facebook GitHub Bot
parent 385473522c
commit 5754b4a123
4 changed files with 61 additions and 0 deletions
@@ -56,6 +56,11 @@ export type ValueStruct = {|
export type CustomHostObject = {};
export type GraphNode = {
label: string,
neighbors?: Array<GraphNode>,
};
export interface Spec extends TurboModule {
+getArray: (arg: Array<ObjectStruct | null>) => Array<ObjectStruct | null>;
+getBool: (arg: boolean) => boolean;
@@ -63,6 +68,7 @@ export interface Spec extends TurboModule {
+getCustomEnum: (arg: EnumInt) => EnumInt;
+getCustomHostObject: () => CustomHostObject;
+consumeCustomHostObject: (customHostObject: CustomHostObject) => string;
+getGraphNode: (arg: GraphNode) => GraphNode;
+getNumEnum: (arg: EnumInt) => EnumFloat;
+getStrEnum: (arg: EnumNone) => EnumStr;
+getMap: (arg: {[key: string]: ?number}) => {[key: string]: ?number};