Skip to content

Commit

Permalink
Update the SSETaskListener implementation to conform to the org.react…
Browse files Browse the repository at this point in the history
…ivestreams.Subscriber interface.
  • Loading branch information
MustafaJadid2025 committed Dec 27, 2024
1 parent a4a442c commit 1fa85a6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ class StreamTests {
functions = FirebaseFunctions.getInstance()
listener =
object : SSETaskListener {
override fun onNext(event: Any) {
onNext.add(event)
override fun onNext(message: Any) {
onNext.add(message)
}

override fun onError(event: Any) {
onError = event
override fun onError(exception: FirebaseFunctionsException) {
onError = exception
}

override fun onComplete(event: Any) {
onComplete = event
override fun onComplete(result: Any) {
onComplete = result
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ internal constructor(
call.enqueue(
object : Callback {
override fun onFailure(ignored: Call, e: IOException) {
val exception: Exception =
val exception: FirebaseFunctionsException =
if (e is InterruptedIOException) {
FirebaseFunctionsException(
FirebaseFunctionsException.Code.DEADLINE_EXCEEDED.name,
Expand Down Expand Up @@ -406,18 +406,18 @@ internal constructor(
if (bodyStream != null) {
processSSEStream(bodyStream, serializer, listener, tcs)
} else {
val error =
val exception =
FirebaseFunctionsException(
"Response body is null",
FirebaseFunctionsException.Code.INTERNAL,
null
)
listener.onError(error)
tcs.setException(error)
listener.onError(exception)
tcs.setException(exception)
}
} catch (e: FirebaseFunctionsException) {
listener.onError(e)
tcs.setException(e)
} catch (exception: FirebaseFunctionsException) {
listener.onError(exception)
tcs.setException(exception)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ package com.google.firebase.functions
public interface SSETaskListener {

/** Called when a new event is received. */
public fun onNext(event: Any)
public fun onNext(message: Any)

/** Called when an error occurs. */
public fun onError(event: Any)
public fun onError(exception: FirebaseFunctionsException)

/** Called when the stream is closed. */
public fun onComplete(event: Any)
public fun onComplete(result: Any)
}

0 comments on commit 1fa85a6

Please sign in to comment.