Skip to content

Commit

Permalink
Migrate EventDispatcher interface to Kotlin (#48445)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #48445

# Changelog:
[Internal] -

As in the title.

Differential Revision: D67760373
  • Loading branch information
rshest authored and facebook-github-bot committed Jan 2, 2025
1 parent 85bb014 commit a68806c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 41 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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.uimanager.events

import com.facebook.react.uimanager.common.UIManagerType

public interface EventDispatcher {
/** Sends the given Event to JS, coalescing eligible events if JS is backed up. */
public fun dispatchEvent(event: Event<*>)

public fun dispatchAllEvents()

/** Add a listener to this EventDispatcher. */
public fun addListener(listener: EventDispatcherListener)

/** Remove a listener from this EventDispatcher. */
public fun removeListener(listener: EventDispatcherListener)

public fun addBatchEventDispatchedListener(listener: BatchEventDispatchedListener)

public fun removeBatchEventDispatchedListener(listener: BatchEventDispatchedListener)

@Deprecated("Use the modern version with RCTModernEventEmitter")
@Suppress("DEPRECATION")
public fun registerEventEmitter(@UIManagerType uiManagerType: Int, eventEmitter: RCTEventEmitter)

public fun registerEventEmitter(
@UIManagerType uiManagerType: Int,
eventEmitter: RCTModernEventEmitter
)

public fun unregisterEventEmitter(@UIManagerType uiManagerType: Int)

public fun onCatalystInstanceDestroyed()
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatcher
import org.mockito.Mockito.argThat
import org.mockito.Mockito.mock
import org.mockito.Mockito.verify
import org.mockito.kotlin.argThat
import org.mockito.kotlin.mock
import org.mockito.kotlin.verify
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment

Expand Down Expand Up @@ -75,7 +75,7 @@ class JSPointerDispatcherTest {
val ev =
createMotionEvent(
MotionEvent.ACTION_DOWN, childRect.centerX().toFloat(), childRect.centerY().toFloat())
val mockDispatcher: EventDispatcher = mock(EventDispatcher::class.java)
val mockDispatcher: EventDispatcher = mock()
pointerDispatcher.handleMotionEvent(ev, mockDispatcher, false)
verify(mockDispatcher).dispatchEvent(argThat(EventWithName(PointerEventHelper.POINTER_DOWN)))
}
Expand Down

0 comments on commit a68806c

Please sign in to comment.