mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Changelog: [Internal] Order of events dispatched to JS matter. If we remove duplicate events, we shouldn't change order of types. So If we have order of events A -> B -> C and inserting a new event A for the same target, we shouldn't delete the first A, as there might be logic that depends on event B being preceded by A. What we can do though, is delete previous event of the same type and target in queue if we would be adding subsequent event. So when we have events A -> B -> C and we are about to add event C to the queue which goes to the same target, we can delete the first C before inserting the new one. Reviewed By: shergin Differential Revision: D22135931 fbshipit-source-id: 1dadd1688516330be07c4251f446f77ca08eaa87
35 lines
795 B
C++
35 lines
795 B
C++
/*
|
|
* 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 <react/core/EventQueue.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
/*
|
|
* Event Queue that dispatches event in batches synchronizing them with
|
|
* an Event Beat.
|
|
*/
|
|
class BatchedEventQueue final : public EventQueue {
|
|
public:
|
|
using EventQueue::EventQueue;
|
|
|
|
void onEnqueue() const override;
|
|
|
|
/*
|
|
* Enqueues and (probably later) dispatch a given event.
|
|
* Deletes last RawEvent from the queu if it has the same type and target.
|
|
* Can be called on any thread.
|
|
*/
|
|
void enqueueUniqueEvent(const RawEvent &rawEvent) const;
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|