UNPKG

1.17 kBtext/x-cView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7#pragma once
8
9#include <memory>
10
11#include <react/events/EventBeat.h>
12#include <react/events/EventQueue.h>
13#include <react/events/RawEvent.h>
14#include <react/events/primitives.h>
15
16namespace facebook {
17namespace react {
18
19class EventDispatcher;
20using SharedEventDispatcher = std::shared_ptr<const EventDispatcher>;
21using WeakEventDispatcher = std::weak_ptr<const EventDispatcher>;
22
23/*
24 * Represents event-delivery infrastructure.
25 * Particular `EventEmitter` clases use this for sending events.
26 */
27class EventDispatcher {
28 public:
29 EventDispatcher(
30 const EventPipe &eventPipe,
31 const EventBeatFactory &synchonousEventBeatFactory,
32 const EventBeatFactory &asynchonousEventBeatFactory);
33
34 /*
35 * Dispatches a raw event with given priority using event-delivery pipe.
36 */
37 void dispatchEvent(const RawEvent &rawEvent, EventPriority priority) const;
38
39 private:
40 std::array<std::unique_ptr<EventQueue>, 4> eventQueues_;
41};
42
43} // namespace react
44} // namespace facebook