mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
d83c310144
Summary: changelog: [internal] There was extra bookkeeping associated with lifetime of `LayoutAnimationCallbackWrapper`. We can just copy it into runtimeExecutor lambda to manage its life cycle and delete `jsi::Function` once it was called. Reviewed By: RSNara Differential Revision: D30728210 fbshipit-source-id: 6fc60ee83846cb73648f1c09e5aaf1ed04bd0817
35 lines
768 B
C++
35 lines
768 B
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <jsi/jsi.h>
|
|
#include <memory>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
class LayoutAnimationCallbackWrapper {
|
|
public:
|
|
LayoutAnimationCallbackWrapper(jsi::Function &&callback)
|
|
: callback_(std::make_shared<jsi::Function>(std::move(callback))) {}
|
|
LayoutAnimationCallbackWrapper() : callback_(nullptr) {}
|
|
|
|
void call(jsi::Runtime &runtime) const {
|
|
if (callback_) {
|
|
callback_->call(runtime);
|
|
callback_.reset();
|
|
}
|
|
}
|
|
|
|
private:
|
|
mutable std::shared_ptr<jsi::Function> callback_;
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|