-
Notifications
You must be signed in to change notification settings - Fork 25.2k
feat: add listener for mount operations on Android #40738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
WoLewicki
wants to merge
12
commits into
react:main
from
WoLewicki:@wolewicki/add-mutations-listener-on-android
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
46a905b
feat: make view recycling optional on iOS
WoLewicki 0e50266
Merge remote-tracking branch 'upstream/main'
WoLewicki a187831
Merge remote-tracking branch 'upstream/main'
WoLewicki 1ae8272
fix: move the logic to RCTComponentViewClassDescriptor
WoLewicki bd63ad8
Merge branch 'main' of https://github.com/facebook/react-native
WoLewicki 63cd56d
Merge branch 'facebook:main' into main
WoLewicki 7feae51
feat: add listener for view mutations
WoLewicki a01c12e
chore: revert changes from main
WoLewicki 746b0bc
fix: class approach for better performance
WoLewicki b595ec1
fix: comment
WoLewicki 887683a
fix: restore missing import for View
WoLewicki 2ca73c7
Merge branch 'main' into @wolewicki/add-mutations-listener-on-android
WoLewicki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...ct-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ViewMutationsListener.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /* | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| package com.facebook.react.bridge; | ||
|
|
||
| import com.facebook.react.fabric.mounting.mountitems.IntBufferMountItem; | ||
|
|
||
| import java.util.ArrayList; | ||
|
|
||
| public interface ViewMutationsListener { | ||
| /** | ||
| * Called right before view mutations are dispatched. This is useful if a | ||
| * module needs to do something before the views are created/removed. | ||
| */ | ||
| void willMountViewMutations(ArrayList<IntBufferMountItem> mutations); | ||
| } |
8 changes: 8 additions & 0 deletions
8
...tAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/InstructionType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.facebook.react.fabric.mounting.mountitems; | ||
|
|
||
| import com.facebook.react.fabric.mounting.mountitems.IntBufferMountItem; | ||
|
|
||
| public enum InstructionType { | ||
| CREATE, DELETE, INSERT, REMOVE, UPDATE_PROPS, UPDATE_STATE, UPDATE_LAYOUT, UPDATE_EVENT_EMITTER, | ||
| UPDATE_PADDING, UPDATE_OVERFLOW_INSET, REMOVE_DELETE_TREE | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...droid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferMountItem.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.facebook.react.fabric.mounting.mountitems; | ||
|
|
||
| import com.facebook.react.fabric.mounting.mountitems.IntBufferMountItem; | ||
| import com.facebook.react.fabric.mounting.mountitems.InstructionType; | ||
|
|
||
| import android.view.View; | ||
|
|
||
| public abstract class IntBufferMountItem { | ||
| private final InstructionType instructionType; | ||
| private final int reactTag; | ||
| private final View view; | ||
|
|
||
| public IntBufferMountItem(InstructionType instructionType, int reactTag, View view) { | ||
| this.instructionType = instructionType; | ||
| this.reactTag = reactTag; | ||
| this.view = view; | ||
| } | ||
|
|
||
| public InstructionType getInstructionType() { | ||
| return instructionType; | ||
| } | ||
|
|
||
| public int getReactTag() { | ||
| return reactTag; | ||
| } | ||
|
|
||
| public View getView() { | ||
| return view; | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
...src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferMountItemCreate.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package com.facebook.react.fabric.mounting.mountitems; | ||
|
|
||
| import com.facebook.react.fabric.mounting.mountitems.InstructionType; | ||
| import com.facebook.react.fabric.mounting.mountitems.IntBufferMountItem; | ||
| import com.facebook.react.uimanager.StateWrapper; | ||
| import com.facebook.react.fabric.events.EventEmitterWrapper; | ||
|
|
||
| import android.view.View; | ||
|
|
||
| public class IntBufferMountItemCreate extends IntBufferMountItem { | ||
|
|
||
| private final String componentName; | ||
| private final Object props; | ||
| private final StateWrapper stateWrapper; | ||
| private final EventEmitterWrapper eventEmitterWrapper; | ||
| private final boolean isLayoutable; | ||
|
|
||
| public IntBufferMountItemCreate(int reactTag, View view, String componentName, Object props, StateWrapper stateWrapper, EventEmitterWrapper eventEmitterWrapper, boolean isLayoutable) { | ||
| super(InstructionType.CREATE, reactTag, view); | ||
| this.componentName = componentName; | ||
| this.props = props; | ||
| this.stateWrapper = stateWrapper; | ||
| this.eventEmitterWrapper = eventEmitterWrapper; | ||
| this.isLayoutable = isLayoutable; | ||
| } | ||
|
|
||
| public String getComponentName() { | ||
| return componentName; | ||
| } | ||
|
|
||
| public Object getProps() { | ||
| return props; | ||
| } | ||
|
|
||
| public StateWrapper getStateWrapper() { | ||
| return stateWrapper; | ||
| } | ||
|
|
||
| public EventEmitterWrapper getEventEmitterWrapper() { | ||
| return eventEmitterWrapper; | ||
| } | ||
|
|
||
| public boolean isLayoutable() { | ||
| return isLayoutable; | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
...src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferMountItemDelete.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.facebook.react.fabric.mounting.mountitems; | ||
|
|
||
| import com.facebook.react.fabric.mounting.mountitems.IntBufferMountItem; | ||
| import com.facebook.react.fabric.mounting.mountitems.InstructionType; | ||
|
|
||
| import android.view.View; | ||
|
|
||
| public class IntBufferMountItemDelete extends IntBufferMountItem { | ||
|
|
||
| public IntBufferMountItemDelete(int reactTag, View view) { | ||
| super(InstructionType.DELETE, reactTag, view); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than creating objects we are increasing cost of this method my resolving Views earlier just to share with the listener, but we are not reusing these views on the call to surfaceMountingManager below, again this method is part of the critical path, and this will bring unnecessary regressions