Skip to content

Commit

Permalink
[LOCAL] Do not use NativeState as JSC does not implement it
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccardo Cipolleschi committed May 25, 2023
1 parent ee177ca commit dc6a2c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jsi::Value RuntimeSchedulerBinding::get(
jsi::Runtime &runtime,
jsi::Value const &,
jsi::Value const *arguments,
size_t) noexcept -> jsi::Value {
size_t count) noexcept -> jsi::Value {
SchedulerPriority priority = fromRawValue(arguments[0].getNumber());
auto callback = arguments[1].getObject(runtime).getFunction(runtime);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@
namespace facebook {
namespace 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> task) {
jsi::Object obj(runtime);
obj.setNativeState(runtime, std::move(task));
return obj;
return jsi::Object::createFromHostObject(
runtime, std::make_shared<TaskWrapper>(task));
}

inline static std::shared_ptr<Task> taskFromValue(
Expand All @@ -28,7 +33,7 @@ inline static std::shared_ptr<Task> taskFromValue(
return nullptr;
}

return value.getObject(runtime).getNativeState<Task>(runtime);
return value.getObject(runtime).getHostObject<TaskWrapper>(runtime)->task;
}

} // namespace react
Expand Down

0 comments on commit dc6a2c3

Please sign in to comment.