mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
08ef1df1ba
Summary: Changelog: [internal] Implement RuntimeScheduler::cancelTask and expose it through JSI. JavaScript implementation: https://github.com/facebook/react/blob/master/packages/scheduler/src/forks/SchedulerNoDOM.js#L384-L397 Reviewed By: mdvacca Differential Revision: D27648071 fbshipit-source-id: 91ae92b336017596fb658831824e971c7e047cd2
40 lines
954 B
C++
40 lines
954 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 <folly/dynamic.h>
|
|
#include <jsi/jsi.h>
|
|
#include <react/renderer/runtimescheduler/Task.h>
|
|
|
|
namespace facebook::react {
|
|
|
|
struct TaskWrapper : public jsi::HostObject {
|
|
TaskWrapper(std::shared_ptr<Task> const &task) : task(task) {}
|
|
|
|
std::shared_ptr<Task> task;
|
|
};
|
|
|
|
inline static jsi::Value valueFromTask(
|
|
jsi::Runtime &runtime,
|
|
std::shared_ptr<Task> const &task) {
|
|
return jsi::Object::createFromHostObject(
|
|
runtime, std::make_shared<TaskWrapper>(task));
|
|
}
|
|
|
|
inline static std::shared_ptr<Task> taskFromValue(
|
|
jsi::Runtime &runtime,
|
|
jsi::Value const &value) {
|
|
if (value.isNull()) {
|
|
return nullptr;
|
|
}
|
|
|
|
return value.getObject(runtime).getHostObject<TaskWrapper>(runtime)->task;
|
|
}
|
|
|
|
} // namespace facebook::react
|