forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert BlackHoleEventDispatcher to Kotlin
Summary: # Changelog: [Internal] - As in the title. Differential Revision: D60283138
- Loading branch information
1 parent
89987ce
commit b6b91f7
Showing
3 changed files
with
64 additions
and
64 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
62 changes: 0 additions & 62 deletions
62
...ctAndroid/src/main/java/com/facebook/react/uimanager/events/BlackHoleEventDispatcher.java
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
...eactAndroid/src/main/java/com/facebook/react/uimanager/events/BlackHoleEventDispatcher.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,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 | ||
} | ||
} |