2018-05-22 22:48:19 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2018-05-22 22:48:19 +00: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 14:21:16 +00:00
|
|
|
#include <folly/dynamic.h>
|
|
|
|
|
2018-05-22 22:48:19 +00:00
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
2018-08-27 14:21:16 +00:00
|
|
|
enum class EventPriority: int {
|
2018-05-22 22:48:19 +00:00
|
|
|
SynchronousUnbatched,
|
|
|
|
SynchronousBatched,
|
|
|
|
AsynchronousUnbatched,
|
|
|
|
AsynchronousBatched,
|
|
|
|
|
|
|
|
Sync = SynchronousUnbatched,
|
|
|
|
Work = SynchronousBatched,
|
|
|
|
Interactive = AsynchronousUnbatched,
|
2018-08-27 14:21:16 +00:00
|
|
|
Deferred = AsynchronousBatched
|
2018-05-22 22:48:19 +00:00
|
|
|
};
|
|
|
|
|
2018-09-14 05:55:58 +00: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-14 05:56:09 +00: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.
|
|
|
|
*
|
|
|
|
* `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-14 05:55:58 +00:00
|
|
|
*/
|
2018-09-14 05:56:09 +00:00
|
|
|
struct EventHandler { virtual ~EventHandler() = default; };
|
|
|
|
using UniqueEventHandler = std::unique_ptr<const EventHandler>;
|
|
|
|
|
|
|
|
struct EventTarget {};
|
2018-09-14 05:56:00 +00:00
|
|
|
using SharedEventTarget = std::shared_ptr<const EventTarget>;
|
|
|
|
using WeakEventTarget = std::weak_ptr<const EventTarget>;
|
2018-05-29 18:20:04 +00:00
|
|
|
|
2018-09-14 05:56:00 +00:00
|
|
|
using EventPipe = std::function<void(const EventTarget *eventTarget, const std::string &type, const folly::dynamic &payload)>;
|
2018-08-27 14:21:16 +00:00
|
|
|
|
2018-05-22 22:48:19 +00:00
|
|
|
} // namespace react
|
|
|
|
} // namespace facebook
|