2018-05-22 15:48:19 -07:00
|
|
|
/**
|
2018-09-11 15:27:47 -07:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2018-05-22 15:48:19 -07:00
|
|
|
*
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-08-27 07:21:16 -07:00
|
|
|
#include <folly/dynamic.h>
|
2018-11-06 10:58:49 -08:00
|
|
|
#include <jsi/jsi.h>
|
2018-08-27 07:21:16 -07:00
|
|
|
|
2018-05-22 15:48:19 -07:00
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
2018-10-09 16:25:13 -07:00
|
|
|
enum class EventPriority : int {
|
2018-05-22 15:48:19 -07:00
|
|
|
SynchronousUnbatched,
|
|
|
|
SynchronousBatched,
|
|
|
|
AsynchronousUnbatched,
|
|
|
|
AsynchronousBatched,
|
|
|
|
|
|
|
|
Sync = SynchronousUnbatched,
|
|
|
|
Work = SynchronousBatched,
|
|
|
|
Interactive = AsynchronousUnbatched,
|
2018-08-27 07:21:16 -07:00
|
|
|
Deferred = AsynchronousBatched
|
2018-05-22 15:48:19 -07:00
|
|
|
};
|
|
|
|
|
2018-09-13 22:55:58 -07:00
|
|
|
/*
|
2018-10-09 16:25:13 -07:00
|
|
|
* We need this types only to ensure type-safety when we deal with them.
|
|
|
|
* Conceptually, they are opaque pointers to some types that derived from those
|
|
|
|
* classes.
|
2018-09-13 22:56:09 -07:00
|
|
|
*
|
|
|
|
* `EventHandler` is managed as a `unique_ptr`, so it must have a *virtual*
|
|
|
|
* destructor to allow proper deallocation having only a pointer
|
|
|
|
* to the base (`EventHandler`) class.
|
|
|
|
*
|
2018-10-09 16:25:13 -07:00
|
|
|
* `EventTarget` is managed as a `shared_ptr`, so it does not need to have a
|
|
|
|
* virtual destructor because `shared_ptr` stores a pointer to destructor
|
|
|
|
* inside.
|
2018-09-13 22:55:58 -07:00
|
|
|
*/
|
2018-10-09 16:25:13 -07:00
|
|
|
struct EventHandler {
|
|
|
|
virtual ~EventHandler() = default;
|
|
|
|
};
|
2018-09-13 22:56:09 -07:00
|
|
|
using UniqueEventHandler = std::unique_ptr<const EventHandler>;
|
|
|
|
|
|
|
|
struct EventTarget {};
|
2018-09-13 22:56:00 -07:00
|
|
|
using SharedEventTarget = std::shared_ptr<const EventTarget>;
|
|
|
|
using WeakEventTarget = std::weak_ptr<const EventTarget>;
|
2018-05-29 11:20:04 -07:00
|
|
|
|
2018-10-09 16:25:13 -07:00
|
|
|
using EventPipe = std::function<void(
|
2018-11-06 10:58:49 -08:00
|
|
|
jsi::Runtime &runtime,
|
2018-10-09 16:25:13 -07:00
|
|
|
const EventTarget *eventTarget,
|
|
|
|
const std::string &type,
|
|
|
|
const folly::dynamic &payload)>;
|
2018-08-27 07:21:16 -07:00
|
|
|
|
2018-05-22 15:48:19 -07:00
|
|
|
} // namespace react
|
|
|
|
} // namespace facebook
|