diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp index eb6ef64aff1..ef4ba32a287 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp @@ -6,6 +6,7 @@ */ #include "RuntimeSchedulerBinding.h" +#include "SchedulerPriority.h" #include @@ -37,8 +38,29 @@ RuntimeSchedulerBinding::createAndInstallIfNeeded(jsi::Runtime &runtime) { jsi::Value RuntimeSchedulerBinding::get( jsi::Runtime &runtime, jsi::PropNameID const &name) { - (void)runtime; - (void)name; + auto propertyName = name.utf8(runtime); + + if (propertyName == "unstable_ImmediatePriority") { + return jsi::Value(runtime, serialize(SchedulerPriority::ImmediatePriority)); + } + + if (propertyName == "unstable_UserBlockingPriority") { + return jsi::Value( + runtime, serialize(SchedulerPriority::UserBlockingPriority)); + } + + if (propertyName == "unstable_NormalPriority") { + return jsi::Value(runtime, serialize(SchedulerPriority::NormalPriority)); + } + + if (propertyName == "unstable_LowPriority") { + return jsi::Value(runtime, serialize(SchedulerPriority::LowPriority)); + } + + if (propertyName == "unstable_IdlePriority") { + return jsi::Value(runtime, serialize(SchedulerPriority::IdlePriority)); + } + return jsi::Value::undefined(); } diff --git a/ReactCommon/react/renderer/runtimescheduler/SchedulerPriority.h b/ReactCommon/react/renderer/runtimescheduler/SchedulerPriority.h new file mode 100644 index 00000000000..cbe1db70e0b --- /dev/null +++ b/ReactCommon/react/renderer/runtimescheduler/SchedulerPriority.h @@ -0,0 +1,26 @@ +/* + * 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 + +namespace facebook::react { + +enum class SchedulerPriority : int { + ImmediatePriority = 1, + UserBlockingPriority = 2, + NormalPriority = 3, + LowPriority = 4, + IdlePriority = 5, +}; + +static constexpr std::underlying_type::type serialize( + SchedulerPriority schedulerPriority) { + return static_cast::type>( + schedulerPriority); +} + +} // namespace facebook::react