Skip to content

Commit 02bf24b

Browse files
rubennortefacebook-github-bot
authored andcommitted
Define continuous and idle priority for raw events and expose them to React via nativeFabricUIManager (#50627)
Summary: Pull Request resolved: #50627 Changelog: [internal] This defines 2 new priorities in Fabric, matching the definitions in React: * Continuous * Idle They're exposed to React via 2 new properties in `nativeFabricUIManager`: `unstable_ContinuousEventPriority` and `unstable_IdleEventPriority`. It also adds the mapping from the raw event priorities to the Fabric event priorities. This change doesn't have any effect at the moment. For these to come into effect, we need to: 1. Fix the mapping between Fabric priorities and React priorities in the React repository. See facebook/react#32847 2. Enable the `fixMappingOfEventPrioritiesBetweenFabricAndReact` feature flag. Reviewed By: javache Differential Revision: D72791968 fbshipit-source-id: 525b6e5c99dc0ddc1e5c60fdb5b73f0555e5f0d3
1 parent 834a633 commit 02bf24b

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "AndroidEventBeat.h"
1111
#include "ComponentFactory.h"
1212
#include "EventBeatManager.h"
13-
#include "EventEmitterWrapper.h"
1413
#include "FabricMountingManager.h"
1514

1615
#include <cxxreact/TraceSection.h>

packages/react-native/ReactCommon/react/renderer/core/EventQueueProcessor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ void EventQueueProcessor::flushEvents(
5555
return ReactEventPriority::Discrete;
5656
case RawEvent::Category::Continuous:
5757
return ReactEventPriority::Continuous;
58+
case RawEvent::Category::Idle:
59+
return ReactEventPriority::Idle;
5860
case RawEvent::Category::Unspecified:
5961
return hasContinuousEventStarted_ ? ReactEventPriority::Continuous
6062
: ReactEventPriority::Default;

packages/react-native/ReactCommon/react/renderer/core/RawEvent.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ struct RawEvent {
5656
* Forces continuous type for the event. Regardless if continuous event
5757
* isn't ongoing.
5858
*/
59-
Continuous = 4
59+
Continuous = 4,
60+
61+
/*
62+
* Priority for events that can be processed in idle times or in the
63+
* background.
64+
*/
65+
Idle = 5,
6066
};
6167

6268
RawEvent(

packages/react-native/ReactCommon/react/renderer/core/ReactEventPriority.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ enum class ReactEventPriority {
3030
* scrolling.
3131
*/
3232
Continuous,
33+
34+
/*
35+
* Other events that can be processed in the background.
36+
*/
37+
Idle,
3338
};
3439

3540
static constexpr std::underlying_type<ReactEventPriority>::type serialize(

packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,14 @@ jsi::Value UIManagerBinding::get(
747747
return {serialize(ReactEventPriority::Discrete)};
748748
}
749749

750+
if (methodName == "unstable_ContinuousEventPriority") {
751+
return {serialize(ReactEventPriority::Continuous)};
752+
}
753+
754+
if (methodName == "unstable_IdleEventPriority") {
755+
return {serialize(ReactEventPriority::Idle)};
756+
}
757+
750758
if (methodName == "findShadowNodeByTag_DEPRECATED") {
751759
auto paramCount = 1;
752760
return jsi::Function::createFromHostFunction(

0 commit comments

Comments
 (0)