Add return value to RuntimeScheduler unstable_scheduleCallback
Summary: Changelog: [internal] unstable_scheduleCallback needs to return reference to the created task so it can be cancelled later. Reviewed By: mdvacca Differential Revision: D27622779 fbshipit-source-id: 54160015c7f98e123d08c2e13efac4f498d3ba5e
This commit is contained in:
Родитель
2779129434
Коммит
3c14c196ca
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "RuntimeSchedulerBinding.h"
|
||||
#include "SchedulerPriority.h"
|
||||
#include "primitives.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <memory>
|
||||
|
@ -65,8 +66,7 @@ jsi::Value RuntimeSchedulerBinding::get(
|
|||
auto task = std::make_shared<Task>(priority, std::move(callback));
|
||||
runtimeScheduler_.scheduleTask(task);
|
||||
|
||||
// TODO: return reference to the task.
|
||||
return jsi::Value::undefined();
|
||||
return valueFromTask(runtime, task);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* 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));
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
Загрузка…
Ссылка в новой задаче