2018-05-22 22:48:19 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
|
|
|
* 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-05-29 21:54:52 +00:00
|
|
|
/* `InstanceHandler`, `EventTarget`, and `EventHandler` are all opaque
|
|
|
|
* raw pointers. We use `struct {} *` trick to differentiate them in compiler's
|
|
|
|
* eyes to ensure type safety.
|
|
|
|
* These structs must have names (and the names must be exported)
|
|
|
|
* to allow consistent template (e.g. `std::function`) instantiating
|
|
|
|
* across different modules.
|
|
|
|
*/
|
|
|
|
using EventTarget = struct EventTargetDummyStruct {} *;
|
|
|
|
using EventHandler = struct EventHandlerDummyStruct {} *;
|
2018-05-29 18:20:04 +00:00
|
|
|
|
2018-08-27 14:21:16 +00:00
|
|
|
/*
|
|
|
|
* EmptyEventTarget is used when some event cannot be dispatched to an original
|
|
|
|
* event target but still has to be dispatched to preserve consistency of event flow.
|
|
|
|
*/
|
|
|
|
static const EventTarget EmptyEventTarget = nullptr;
|
|
|
|
|
|
|
|
using EventPipe = std::function<void(const EventTarget &eventTarget, const std::string &type, const folly::dynamic &payload)>;
|
|
|
|
|
2018-05-22 22:48:19 +00:00
|
|
|
} // namespace react
|
|
|
|
} // namespace facebook
|