mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Rename Instance::getNativeCallinvoker to Instance::getDecoratedNativeCallInvoker
Summary: Now, instead of accepting a `std::function` that schedules work, and returning a `CallInvoker`, `Instance::getDecoratedNativeCallInvoker` will accept a `CallInvoker` that schedules work, and return a decorated `CallInvoker`. I think this change will help with readability. It also clarifies that the bridge is adding additional behaviour to the native `CallInvoker`. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D20826885 fbshipit-source-id: a2c5681d10a4544ee3d2a0d1f1cbd386ef06d0e6
This commit is contained in:
1 parent
83fee73ae6
commit
eb4e2baaa9
5 files changed
+38
-25
No files matched your search
@@ -297,12 +297,27 @@ CatalystInstanceImpl::getJSCallInvokerHolder() {
|
||||
jni::alias_ref<CallInvokerHolder::javaobject>
|
||||
CatalystInstanceImpl::getNativeCallInvokerHolder() {
|
||||
if (!nativeCallInvokerHolder_) {
|
||||
class NativeThreadCallInvoker : public CallInvoker {
|
||||
private:
|
||||
std::shared_ptr<JMessageQueueThread> messageQueueThread_;
|
||||
|
||||
public:
|
||||
NativeThreadCallInvoker(
|
||||
std::shared_ptr<JMessageQueueThread> messageQueueThread)
|
||||
: messageQueueThread_(messageQueueThread) {}
|
||||
void invokeAsync(std::function<void()> &&work) override {
|
||||
messageQueueThread_->runOnQueue(std::move(work));
|
||||
}
|
||||
};
|
||||
|
||||
std::shared_ptr<CallInvoker> nativeInvoker =
|
||||
std::make_shared<NativeThreadCallInvoker>(moduleMessageQueue_);
|
||||
|
||||
std::shared_ptr<CallInvoker> decoratedNativeInvoker =
|
||||
instance_->getDecoratedNativeCallInvoker(nativeInvoker);
|
||||
|
||||
nativeCallInvokerHolder_ = jni::make_global(
|
||||
CallInvokerHolder::newObjectCxxArgs(instance_->getNativeCallInvoker(
|
||||
[moduleMessageQueue =
|
||||
moduleMessageQueue_](std::function<void()> &&work) {
|
||||
moduleMessageQueue->runOnQueue(std::move(work));
|
||||
})));
|
||||
CallInvokerHolder::newObjectCxxArgs(decoratedNativeInvoker));
|
||||
}
|
||||
|
||||
return nativeCallInvokerHolder_;
|
||||
|
||||
Reference in new issue
Block a user