File tree Expand file tree Collapse file tree 3 files changed +37
-44
lines changed
packages/react-native/ReactAndroid/src
main/java/com/facebook/react/bridge
test/java/com/facebook/react/bridge Expand file tree Collapse file tree 3 files changed +37
-44
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and 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
+
8
+ package com.facebook.react.bridge
9
+
10
+ import com.facebook.react.common.annotations.internal.LegacyArchitecture
11
+ import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel
12
+ import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger
13
+
14
+ /* * Implementation of javascript callback function that uses Bridge to schedule method execution. */
15
+ @LegacyArchitecture
16
+ public class CallbackImpl (private val jsInstance : JSInstance , private val callbackId : Int ) :
17
+ Callback {
18
+ private var invoked = false
19
+
20
+ override fun invoke (vararg args : Any? ) {
21
+ if (invoked) {
22
+ throw RuntimeException (
23
+ " Illegal callback invocation from native module. This callback type only permits a single invocation from native code." )
24
+ }
25
+ jsInstance.invokeCallback(callbackId, Arguments .fromJavaArgs(args))
26
+ invoked = true
27
+ }
28
+
29
+ private companion object {
30
+ init {
31
+ LegacyArchitectureLogger .assertWhenLegacyArchitectureMinifyingEnabled(
32
+ " CallbackImpl" , LegacyArchitectureLogLevel .WARNING )
33
+ }
34
+ }
35
+ }
Original file line number Diff line number Diff line change @@ -30,8 +30,9 @@ class BaseJavaModuleTest {
30
30
31
31
@Before
32
32
fun setup () {
33
+ val jsInstance = mock(JSInstance ::class .java)
33
34
val moduleHolder = ModuleHolder (MethodsModule ())
34
- moduleWrapper = JavaModuleWrapper (null , moduleHolder)
35
+ moduleWrapper = JavaModuleWrapper (jsInstance , moduleHolder)
35
36
methods = moduleWrapper.methodDescriptors
36
37
val generatedModuleHolder = ModuleHolder (GeneratedMethodsModule ())
37
38
generatedModuleWrapper = JavaModuleWrapper (null , generatedModuleHolder)
You can’t perform that action at this time.
0 commit comments