/* * 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 #include #include #include #include #include namespace facebook { namespace react { struct RawEvent; /* * Represents event-delivery infrastructure. * Particular `EventEmitter` clases use this for sending events. */ class EventDispatcher { public: using Shared = std::shared_ptr; using Weak = std::weak_ptr; EventDispatcher( EventQueueProcessor eventProcessor, EventBeat::Factory const &synchonousEventBeatFactory, EventBeat::Factory const &asynchonousEventBeatFactory, EventBeat::SharedOwnerBox const &ownerBox); /* * Dispatches a raw event with given priority using event-delivery pipe. */ void dispatchEvent(RawEvent &&rawEvent, EventPriority priority) const; /* * Dispatches a raw event with asynchronous batched priority. Before the * dispatch we make sure that no other RawEvent of same type and same target * is on the queue. */ void dispatchUniqueEvent(RawEvent &&rawEvent) const; /* * Dispatches a state update with given priority. */ void dispatchStateUpdate(StateUpdate &&stateUpdate, EventPriority priority) const; private: EventQueue const &getEventQueue(EventPriority priority) const; std::unique_ptr synchronousUnbatchedQueue_; std::unique_ptr synchronousBatchedQueue_; std::unique_ptr asynchronousUnbatchedQueue_; std::unique_ptr asynchronousBatchedQueue_; }; } // namespace react } // namespace facebook