-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: event name conflicts with other libs using RCTDeviceEventEmitter (…
…#70) * Create PusherEventEmitter on Android with event prefix * Use PusherReactNative event prefix on iOS events * Add package locks to the repo * Bump to version 1.2.1 Co-authored-by: Pusher CI <[email protected]>
- Loading branch information
1 parent
393b112
commit 0ec7faf
Showing
8 changed files
with
21,290 additions
and
46 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
24 changes: 24 additions & 0 deletions
24
android/src/main/java/com/pusherwebsocketreactnative/PusherEventEmitter.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,24 @@ | ||
package com.pusherwebsocketreactnative | ||
|
||
import com.facebook.react.bridge.Arguments | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.modules.core.DeviceEventManagerModule | ||
|
||
class PusherEventEmitter(private val context: ReactApplicationContext) { | ||
companion object { | ||
private const val EVENT_PREFIX = "PusherReactNative" | ||
} | ||
|
||
fun emit(eventName: String, params: Any?) { | ||
val jsModule = this.context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java) | ||
val pusherEventName = "${EVENT_PREFIX}:${eventName}" | ||
|
||
if (params is Map<*, *>) { | ||
jsModule.emit(pusherEventName, Arguments.makeNativeMap(params as Map<String, Any>)) | ||
} | ||
|
||
if (params is String) { | ||
jsModule.emit(pusherEventName, params) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.