-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Bridgeless with runtimeExecutor (#5734)
PR bringing 0.74/bridgeless mode support to the library. --------- Co-authored-by: Tomasz Żelawski <40713406+tjzel@users.noreply.github.com> Co-authored-by: Tomasz Żelawski <tomasz.zelawski@swmansion.com>
- Loading branch information
1 parent
102db0a
commit 2eb2882
Showing
20 changed files
with
1,233 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
#include "JSScheduler.h" | ||
|
||
#include <utility> | ||
using namespace facebook; | ||
using namespace react; | ||
|
||
namespace reanimated { | ||
JSScheduler::JSScheduler( | ||
jsi::Runtime &rnRuntime, | ||
const std::shared_ptr<CallInvoker> &jsCallInvoker) | ||
: rnRuntime_(rnRuntime), | ||
jsCallInvoker_(jsCallInvoker), | ||
scheduleOnJS([&](Job job) { | ||
jsCallInvoker_->invokeAsync( | ||
[job = std::move(job), &rt = rnRuntime_] { job(rt); }); | ||
}) {} | ||
|
||
void JSScheduler::scheduleOnJS(std::function<void(jsi::Runtime &rt)> job) { | ||
jsCallInvoker_->invokeAsync( | ||
[job = std::move(job), &rt = rnRuntime_] { job(rt); }); | ||
} | ||
#if REACT_NATIVE_MINOR_VERSION >= 74 && defined(RCT_NEW_ARCH_ENABLED) | ||
// With `runtimeExecutor`. | ||
JSScheduler::JSScheduler( | ||
jsi::Runtime &rnRuntime, | ||
RuntimeExecutor runtimeExecutor) | ||
: rnRuntime_(rnRuntime), | ||
runtimeExecutor_(runtimeExecutor), | ||
scheduleOnJS([&](Job job) { | ||
runtimeExecutor_( | ||
[job = std::move(job)](jsi::Runtime &runtime) { job(runtime); }); | ||
}) {} | ||
#endif // REACT_NATIVE_MINOR_VERSION >= 74 && defined(RCT_NEW_ARCH_ENABLED | ||
|
||
} // namespace reanimated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,42 @@ | ||
#pragma once | ||
|
||
#include <ReactCommon/CallInvoker.h> | ||
#include <ReactCommon/RuntimeExecutor.h> | ||
#include <jsi/jsi.h> | ||
|
||
#include <memory> | ||
#include <utility> | ||
|
||
using namespace facebook; | ||
using namespace react; | ||
|
||
using Job = std::function<void(jsi::Runtime &rt)>; | ||
|
||
namespace reanimated { | ||
|
||
class JSScheduler { | ||
public: | ||
// With `jsCallInvoker`. | ||
explicit JSScheduler( | ||
jsi::Runtime &rnRuntime, | ||
const std::shared_ptr<CallInvoker> &jsCallInvoker); | ||
|
||
#if REACT_NATIVE_MINOR_VERSION >= 74 && defined(RCT_NEW_ARCH_ENABLED) | ||
// With `runtimeExecutor`. | ||
explicit JSScheduler( | ||
jsi::Runtime &rnRuntime, | ||
const std::shared_ptr<facebook::react::CallInvoker> &jsCallInvoker) | ||
: rnRuntime_(rnRuntime), jsCallInvoker_(jsCallInvoker) {} | ||
void scheduleOnJS(std::function<void(jsi::Runtime &rt)> job); | ||
RuntimeExecutor runtimeExecutor); | ||
#endif // REACT_NATIVE_MINOR_VERSION >= 74 && defined(RCT_NEW_ARCH_ENABLED | ||
|
||
protected: | ||
jsi::Runtime &rnRuntime_; | ||
const std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker_; | ||
const std::shared_ptr<CallInvoker> jsCallInvoker_ = nullptr; | ||
#if REACT_NATIVE_MINOR_VERSION >= 74 && defined(RCT_NEW_ARCH_ENABLED) | ||
RuntimeExecutor runtimeExecutor_ = nullptr; | ||
#endif // REACT_NATIVE_MINOR_VERSION >= 74 && defined(RCT_NEW_ARCH_ENABLED | ||
|
||
public: | ||
const std::function<void(Job)> scheduleOnJS = nullptr; | ||
}; | ||
|
||
} // namespace reanimated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ - (NSURL *)bundleURL | |
|
||
- (BOOL)bridgelessEnabled | ||
{ | ||
return NO; | ||
return YES; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.