Skip to content

POC PR for Addressing issue 26 and issue 25#27

Open
eye-dee wants to merge 2 commits intopratikbaid3:masterfrom
eye-dee:feature/close-stream-when-done
Open

POC PR for Addressing issue 26 and issue 25#27
eye-dee wants to merge 2 commits intopratikbaid3:masterfrom
eye-dee:feature/close-stream-when-done

Conversation

@eye-dee
Copy link
Copy Markdown

@eye-dee eye-dee commented Aug 7, 2024

POC PR for Addressing #26 and #25

@eye-dee eye-dee changed the title POC PR for Addressing https://github.com/pratikbaid3/flutter_client_sse/issues/26 and https://github.com/pratikbaid3/flutter_client_sse/issues/25 POC PR for Addressing issue 26 and issue 25 Aug 7, 2024
/// A client for subscribing to Server-Sent Events (SSE).
class SSEClient {
static http.Client _client = new http.Client();
static StreamController<SSEModel> _streamController = StreamController();
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static stream limits the client to be used only once

Comment thread test/sse_client_test.dart Outdated
header: {},
);

// TODO
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about infinite retry
If I understood it correctly, it might cause stack overflow

maybe the method itself should be reworked to yield stream

Stream asynchronousNaturalsTo(n) async* {
  int k = 0;
  while (k < n) yield k++;
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great sugggestion. I was also thinking of privigind a config object direct from the client using the package. This will allow more control over the newtwork calls.

@eye-dee eye-dee force-pushed the feature/close-stream-when-done branch from 878737d to 88c9b55 Compare August 7, 2024 19:20
static StreamController<SSEModel> _streamController = StreamController();
final http.Client _client;

SSEClient(this._client);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clients of the library will be responsible for managing the client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants