Imgkl / EventFlux

A Dart package for efficient handling of server-sent event streams with easy connectivity and data management.
https://pub.dev/packages/eventflux
MIT License
25 stars 8 forks source link

Add Http Client Adapter to allow usage of different http clients #26

Closed jcarvalho-ptech closed 2 months ago

Imgkl commented 2 months ago

Hey @jcarvalho-ptech Thanks for this PR. Feature definitely sounds interesting.

I'll test it with couple of different clients and I'll update the PR.

jcarvalho-ptech commented 2 months ago

Thanks @Imgkl !

This would allow us to use any http client. An example using Chopper:

class EventFluxClientAdapter implements HttpClientAdapter {
  @override
  Future<StreamedResponse> send(BaseRequest request) async {
    chopper.ChopperClient client = GetIt.I.get(instanceName: "chopperClient");
    StreamedResponse response = (await client.send<Stream<List<int>>, String>(
            chopper.Request("GET", request.url, Uri.parse(""),
                headers: request.headers)))
        .base as StreamedResponse;
    return response;
   ...

And feel free to improve the PR!

Imgkl commented 2 months ago

@jcarvalho-ptech Thanks for the example.