|
6 | 6 | // ignore_for_file: public_member_api_docs
|
7 | 7 |
|
8 | 8 | import 'dart:js_interop';
|
9 |
| - |
10 | 9 | import 'package:firebase_core_web/firebase_core_web_interop.dart';
|
11 | 10 |
|
12 | 11 | import 'functions_interop.dart' as functions_interop;
|
@@ -84,6 +83,19 @@ class HttpsCallable extends JsObjectWrapper<JSFunction> {
|
84 | 83 | result! as functions_interop.HttpsCallableResultJsImpl,
|
85 | 84 | );
|
86 | 85 | }
|
| 86 | + |
| 87 | + Stream<HttpsCallableResult> stream(JSAny? data) async* { |
| 88 | + final streamCallable = |
| 89 | + await (jsObject as functions_interop.HttpsCallable).stream().toDart; |
| 90 | + final streamResult = |
| 91 | + streamCallable! as functions_interop.HttpsCallableStreamResultJsImpl; |
| 92 | + |
| 93 | + await for (final value in streamResult.stream.asStream()) { |
| 94 | + yield HttpsCallableResult.getInstance( |
| 95 | + value as functions_interop.HttpsCallableResultJsImpl, |
| 96 | + ); |
| 97 | + } |
| 98 | + } |
87 | 99 | }
|
88 | 100 |
|
89 | 101 | /// Returns Dart representation from JS Object.
|
@@ -137,3 +149,25 @@ class HttpsCallableResult
|
137 | 149 | return _data;
|
138 | 150 | }
|
139 | 151 | }
|
| 152 | + |
| 153 | +class HttpsCallableStreamResult |
| 154 | + extends JsObjectWrapper<functions_interop.HttpsCallableStreamResultJsImpl> { |
| 155 | + HttpsCallableStreamResult._fromJsObject( |
| 156 | + functions_interop.HttpsCallableStreamResultJsImpl jsObject) |
| 157 | + : _data = _dartify(jsObject.data), |
| 158 | + super.fromJsObject(jsObject); |
| 159 | + |
| 160 | + static final _expando = Expando<HttpsCallableStreamResult>(); |
| 161 | + final dynamic _data; |
| 162 | + |
| 163 | + /// Creates a new HttpsCallableResult from a [jsObject]. |
| 164 | + static HttpsCallableStreamResult getInstance( |
| 165 | + functions_interop.HttpsCallableStreamResultJsImpl jsObject) { |
| 166 | + return _expando[jsObject] ??= |
| 167 | + HttpsCallableStreamResult._fromJsObject(jsObject); |
| 168 | + } |
| 169 | + |
| 170 | + dynamic get data { |
| 171 | + return _data; |
| 172 | + } |
| 173 | +} |
0 commit comments