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:
committed by
Facebook GitHub Bot
parent
83fee73ae6
commit
eb4e2baaa9
@@ -302,30 +302,29 @@ void NativeToJsBridge::runOnExecutorQueue(
|
||||
});
|
||||
}
|
||||
|
||||
std::shared_ptr<CallInvoker> NativeToJsBridge::getNativeCallInvoker(
|
||||
std::function<void(std::function<void()> &&work)> &&scheduleWork) {
|
||||
std::shared_ptr<CallInvoker> NativeToJsBridge::getDecoratedNativeCallInvoker(
|
||||
std::shared_ptr<CallInvoker> nativeInvoker) {
|
||||
class NativeCallInvoker : public CallInvoker {
|
||||
private:
|
||||
std::weak_ptr<JsToNativeBridge> m_jsToNativeBridge;
|
||||
std::function<void(std::function<void()> &&work)> m_scheduleWork;
|
||||
std::shared_ptr<CallInvoker> m_nativeInvoker;
|
||||
|
||||
public:
|
||||
NativeCallInvoker(
|
||||
std::weak_ptr<JsToNativeBridge> jsToNativeBridge,
|
||||
std::function<void(std::function<void()> &&work)> &&scheduleWork)
|
||||
std::shared_ptr<CallInvoker> nativeInvoker)
|
||||
: m_jsToNativeBridge(jsToNativeBridge),
|
||||
m_scheduleWork(std::move(scheduleWork)) {}
|
||||
m_nativeInvoker(nativeInvoker) {}
|
||||
|
||||
void invokeAsync(std::function<void()> &&func) override {
|
||||
if (auto strongJsToNativeBridge = m_jsToNativeBridge.lock()) {
|
||||
strongJsToNativeBridge->recordTurboModuleAsyncMethodCall();
|
||||
}
|
||||
m_scheduleWork(std::move(func));
|
||||
m_nativeInvoker->invokeAsync(std::move(func));
|
||||
}
|
||||
};
|
||||
|
||||
return std::make_shared<NativeCallInvoker>(
|
||||
m_delegate, std::move(scheduleWork));
|
||||
return std::make_shared<NativeCallInvoker>(m_delegate, nativeInvoker);
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
|
||||
Reference in New Issue
Block a user