/* * 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. */ #pragma once #include #include namespace facebook { namespace react { struct TaskWrapper : public jsi::HostObject { TaskWrapper(std::shared_ptr const &task) : task(task) {} std::shared_ptr task; }; inline static jsi::Value valueFromTask( jsi::Runtime &runtime, std::shared_ptr task) { return jsi::Object::createFromHostObject( runtime, std::make_shared(task)); } inline static std::shared_ptr taskFromValue( jsi::Runtime &runtime, jsi::Value const &value) { if (value.isNull()) { return nullptr; } return value.getObject(runtime).getHostObject(runtime)->task; } } // namespace react } // namespace facebook