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
@@ -65,6 +65,16 @@ std::string NativeCxxModuleExample::consumeCustomHostObject(
return value->a_ + std::to_string(value->b_);
}
GraphNode NativeCxxModuleExample::getGraphNode(
jsi::Runtime& rt,
GraphNode arg) {
if (arg.neighbors) {
arg.neighbors->emplace_back(GraphNode{.label = "top"});
arg.neighbors->emplace_back(GraphNode{.label = "down"});
}
return arg;
}
NativeCxxModuleExampleCxxEnumFloat NativeCxxModuleExample::getNumEnum(
jsi::Runtime& rt,
NativeCxxModuleExampleCxxEnumInt arg) {