Closed dshukertjr closed 1 month ago
Additional Context
On Flutter Web, the stream emits data only when the server is done sending the entire events. See the following issue for more info dart-lang/http#337
Thanks for your effort!
But is there no possibility for it to work in web? I managed to make it work in web (with older gotrue/supabase-flutter version) using flutter_client_sse
and especially fetch_client
. Could there be an option to use fetch_client
as alternate http
client as darts HttpClient
does not support it yet.
Maybe like it is done in here: https://github.com/pratikbaid3/flutter_client_sse/issues/19#issuecomment-1925033427
There is the option to provide an httpClientProvider
so I can use fetch_client
instead of dart-lang http
for web.
This would make it possible to support streaming in web too.
@nietsmmar Actually, just by passing fetch client, I was able to stream SSE on the web!
final client = FetchClient(mode: RequestMode.cors);
await Supabase.initialize(
url: supabaseUrl,
anonKey: supabaseKey,
debug: false,
httpClient: kIsWeb ? client : null,
);
What kind of change does this PR introduce?
Adds support for streaming response of an edge function that returns Server Sent Events.
Fixes https://github.com/supabase/supabase-flutter/issues/894
What is the current behavior?
There is no support for SSE, and developers have to use other libraries to listen to SSE.
What is the new behavior?
Users can listen to SSE like the following:
Additional Context
On the web, you would need to pass a custom HTTP client like this: