Skip to content

Commit

Permalink
Convert BlackHoleEventDispatcher to Kotlin
Browse files Browse the repository at this point in the history
Summary:
# Changelog:
[Internal] -

As in the title.

Differential Revision: D60283138
  • Loading branch information
rshest authored and facebook-github-bot committed Jul 26, 2024
1 parent 89987ce commit b6b91f7
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 64 deletions.
9 changes: 7 additions & 2 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -5549,12 +5549,13 @@ public abstract interface class com/facebook/react/uimanager/events/BatchEventDi
public abstract fun onBatchEventDispatched ()V
}

public class com/facebook/react/uimanager/events/BlackHoleEventDispatcher : com/facebook/react/uimanager/events/EventDispatcher {
public final class com/facebook/react/uimanager/events/BlackHoleEventDispatcher : com/facebook/react/uimanager/events/EventDispatcher {
public static final field Companion Lcom/facebook/react/uimanager/events/BlackHoleEventDispatcher$Companion;
public fun addBatchEventDispatchedListener (Lcom/facebook/react/uimanager/events/BatchEventDispatchedListener;)V
public fun addListener (Lcom/facebook/react/uimanager/events/EventDispatcherListener;)V
public fun dispatchAllEvents ()V
public fun dispatchEvent (Lcom/facebook/react/uimanager/events/Event;)V
public static fun get ()Lcom/facebook/react/uimanager/events/EventDispatcher;
public static final fun get ()Lcom/facebook/react/uimanager/events/EventDispatcher;
public fun onCatalystInstanceDestroyed ()V
public fun registerEventEmitter (ILcom/facebook/react/uimanager/events/RCTEventEmitter;)V
public fun registerEventEmitter (ILcom/facebook/react/uimanager/events/RCTModernEventEmitter;)V
Expand All @@ -5563,6 +5564,10 @@ public class com/facebook/react/uimanager/events/BlackHoleEventDispatcher : com/
public fun unregisterEventEmitter (I)V
}

public final class com/facebook/react/uimanager/events/BlackHoleEventDispatcher$Companion {
public final fun get ()Lcom/facebook/react/uimanager/events/EventDispatcher;
}

public final class com/facebook/react/uimanager/events/ContentSizeChangeEvent : com/facebook/react/uimanager/events/Event {
public fun <init> (III)V
public fun <init> (IIII)V
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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.common.logging.FLog

/**
* A singleton class that overrides [EventDispatcher] with no-op methods, to be used by callers that
* expect an EventDispatcher when the instance doesn't exist.
*/
public class BlackHoleEventDispatcher private constructor() : EventDispatcher {
public override fun dispatchEvent(event: Event<*>) {
FLog.d(
javaClass.simpleName,
"Trying to emit event to JS, but the React instance isn't ready. Event: ${event.eventName}")
}

public override fun dispatchAllEvents(): Unit = Unit

public override fun addListener(listener: EventDispatcherListener): Unit = Unit

public override fun removeListener(listener: EventDispatcherListener): Unit = Unit

public override fun addBatchEventDispatchedListener(
listener: BatchEventDispatchedListener
): Unit = Unit

public override fun removeBatchEventDispatchedListener(
listener: BatchEventDispatchedListener
): Unit = Unit

@Suppress("DEPRECATION")
public override fun registerEventEmitter(
uiManagerType: Int,
eventEmitter: RCTEventEmitter
): Unit = Unit

public override fun registerEventEmitter(
uiManagerType: Int,
eventEmitter: RCTModernEventEmitter
): Unit = Unit

public override fun unregisterEventEmitter(uiManagerType: Int): Unit = Unit

public override fun onCatalystInstanceDestroyed(): Unit = Unit

public companion object {
private val eventDispatcher: EventDispatcher = BlackHoleEventDispatcher()

public @JvmStatic fun get(): EventDispatcher = eventDispatcher
}
}

0 comments on commit b6b91f7

Please sign in to comment.