-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shortcut emitDeviceEvent in bridgeless (2nd attempt) (#44590)
Summary: Pull Request resolved: #44590 emitDeviceEvent is frequently used for perf-critical operations such as sending network responses from native to JS. We don't need to go through JavaScriptModule Proxy (which is missing caching in bridgeless) and instead can immediately invoke the callable JS module. Changelog: [Internal] Reviewed By: philIip Differential Revision: D57435750 fbshipit-source-id: 1c120073ac80afd95deb8e3e6f1c00c2d3d80133
- Loading branch information
1 parent
1343313
commit b2ced62
Showing
4 changed files
with
82 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
29 changes: 29 additions & 0 deletions
29
...act-native/ReactAndroid/src/test/java/com/facebook/testutils/shadows/ShadowNativeArray.kt
This file contains 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,29 @@ | ||
/* | ||
* 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.testutils.shadows | ||
|
||
import com.facebook.react.bridge.NativeArray | ||
import com.facebook.react.bridge.ReadableNativeArray | ||
import com.facebook.react.bridge.WritableNativeArray | ||
import org.robolectric.annotation.Implements | ||
import org.robolectric.shadow.api.Shadow | ||
|
||
// Mockito can't mock native methods, so shadow the entire class instead | ||
@Implements(NativeArray::class) | ||
public open class ShadowNativeArray { | ||
public var contents: List<Any?> = mutableListOf() | ||
|
||
@Implements(ReadableNativeArray::class) public class Readable : ShadowNativeArray() {} | ||
|
||
@Implements(WritableNativeArray::class) public class Writable : ShadowNativeArray() {} | ||
|
||
public companion object { | ||
public fun getContents(array: NativeArray): List<Any?> = | ||
(Shadow.extract(array) as ShadowNativeArray).contents | ||
} | ||
} |