@@ -17,6 +17,8 @@ import androidx.annotation.VisibleForTesting
17
17
import com.google.android.gms.tasks.Task
18
18
import java.net.URL
19
19
import java.util.concurrent.TimeUnit
20
+ import kotlinx.coroutines.flow.Flow
21
+ import kotlinx.coroutines.reactive.asFlow
20
22
import org.reactivestreams.Publisher
21
23
22
24
/* * A reference to a particular Callable HTTPS trigger in Cloud Functions. */
@@ -173,6 +175,49 @@ public class HttpsCallableReference {
173
175
}
174
176
}
175
177
178
+ /* *
179
+ * Streams data to the specified HTTPS endpoint.
180
+ *
181
+ * The data passed into the trigger can be any of the following types:
182
+ *
183
+ * * Any primitive type, including null, int, long, float, and boolean.
184
+ * * [String]
185
+ * * [List<?>][java.util.List], where the contained objects are also one of these types.
186
+ * * [Map<String, ?>][java.util.Map], where the values are also one of these types.
187
+ * * [org.json.JSONArray]
188
+ * * [org.json.JSONObject]
189
+ * * [org.json.JSONObject.NULL]
190
+ *
191
+ * If the returned streamResponse fails, the exception will be one of the following types:
192
+ *
193
+ * * [java.io.IOException]
194
+ * - if the HTTPS request failed to connect.
195
+ * * [FirebaseFunctionsException]
196
+ * - if the request connected, but the function returned an error.
197
+ *
198
+ * The request to the Cloud Functions backend made by this method automatically includes a
199
+ * Firebase Instance ID token to identify the app instance. If a user is logged in with Firebase
200
+ * Auth, an auth token for the user will also be automatically included.
201
+ *
202
+ * Firebase Instance ID sends data to the Firebase backend periodically to collect information
203
+ * regarding the app instance. To stop this, see
204
+ * [com.google.firebase.iid.FirebaseInstanceId.deleteInstanceId]. It will resume with a new
205
+ * Instance ID the next time you call this method.
206
+ *
207
+ * @param data Parameters to pass to the endpoint. Defaults to `null` if not provided.
208
+ * @return [Flow] that will emit intermediate data, and the final result, as it is generated by
209
+ * the function.
210
+ * @see org.json.JSONArray
211
+ *
212
+ * @see org.json.JSONObject
213
+ *
214
+ * @see java.io.IOException
215
+ *
216
+ * @see FirebaseFunctionsException
217
+ */
218
+ @JvmOverloads
219
+ public fun streamAsFlow (data : Any? = null): Flow <StreamResponse > = stream(data).asFlow()
220
+
176
221
/* *
177
222
* Changes the timeout for calls from this instance of Functions. The default is 60 seconds.
178
223
*
0 commit comments