Files
react-native/packages/react-native/React/Base/RCTRuntimeExecutorModule.h
T
Phillip Pan 343a0d3cd8 introduce native api to access RuntimeExecutor (#42758)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42758

Changelog: [iOS][Added] - introduce native api to access RuntimeExecutor

The goal of this API is to provide a safe way to access the `jsi::runtime` in bridgeless mode. The decision to limit access to the runtime in bridgeless was a conscious one - the runtime pointer is not thread-safe and its lifecycle must be managed correctly by owners.

However, interacting with the runtime is an advanced use case we would want to support. Our recommended ways to access the runtime in bridgeless mode is either 1) via the RuntimeExecutor, or 2) via a C++ TurboModule.

This diff introduces the API that would allow for 1). The integration consists of these parts:
- wrapper object for RuntimeExecutor access, `RCTRuntimeExecutor`. The NSObject wrapper is necessary so we can make it the property of a swift module
- new protocol API,`RCTRuntimeExecutionModule`, for modules to access the RuntimeExecutor block
- integration within the bridgeless infrastructure

Reviewed By: javache

Differential Revision: D53256188

fbshipit-source-id: 8fadbe8f760cdb8928bbf3f7e4829e27b7617b9d
2024-02-06 03:56:48 -08:00

19 lines
481 B
Objective-C

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
@class RCTRuntimeExecutor;
/**
* Have your module conform to this protocol to access the RuntimeExecutor.
* Only available in the bridgeless runtime.
*/
@protocol RCTRuntimeExecutorModule <NSObject>
@property (nonatomic, nullable, readwrite) RCTRuntimeExecutor *runtimeExecutor;
@end