stream method

  1. @override
Stream stream(
  1. Object? parameters
)

Streams data to the specified HTTPS endpoint.

The data passed into the trigger can be any of the following types:

null String num List, where the contained objects are also one of these types. Map, where the values are also one of these types.

The request to the Cloud Functions backend made by this method automatically includes a Firebase Instance ID token to identify the app instance. If a user is logged in with Firebase Auth, an auth ID token for the user is also automatically included.

Implementation

@override
Stream<dynamic> stream(Object? parameters) async* {
  if (origin != null) {
    final uri = Uri.parse(origin!);

    _webFunctions.useFunctionsEmulator(uri.host, uri.port);
  }

  late functions_interop.HttpsCallable callable;

  if (name != null) {
    callable = _webFunctions.httpsCallable(name!);
  } else if (uri != null) {
    callable = _webFunctions.httpsCallableUri(uri!);
  } else {
    throw ArgumentError('Either name or uri must be provided');
  }

  final JSAny? parametersJS = parameters?.jsify();
  web.AbortSignal? signal;
  if (options.webAbortSignal != null) {
    signal = _createJsAbortSignal(options.webAbortSignal!);
  }
  interop.HttpsCallableStreamOptions callableStreamOptions =
      interop.HttpsCallableStreamOptions(
          limitedUseAppCheckTokens: options.limitedUseAppCheckToken.toJS,
          signal: signal);
  try {
    await for (final value
        in callable.stream(parametersJS, callableStreamOptions)) {
      yield value;
    }
  } catch (e, s) {
    throw convertFirebaseFunctionsException(e as JSObject, s);
  }
}