-
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Make sure sse async channel gets closed. #63
Conversation
Thanks for your contribution! I have done a few tests and mostly looks good, but I have noticed a (potential) regression with this example The first time the I am away for 2 weeks and won't be able to look further but maybe you could give it some thought, I am happy to merge when I return |
Yes, my change probably would break that example (I haven't tested, but logically the channel will always receive On the one hand, if lots of folks used this example as a template, then the attached pull request would be breaking change. On the other hand, I do think that stopping on I would write the example like: (a/go
(loop []
;; use when-let instead of let
(when-let [event (a/<! events)]
;; when (not= :done event) not needed if `events` closes itself
;; Do something with the event token
(prn event)
(recur)))) Maybe there's a way to make the change backwards compatible? A backwards compatible option might be to add a Thanks for the library! |
A Also, if it's not too much trouble, a basic unit test would be great 🙂 |
393a38f
to
36ddb35
Compare
I've rebased onto master and made the following updates:
Thanks again @wkok ! Let me know if you'd like any other changes. |
Looks good to me 👍 Thanks for your contribution! |
The events async channel does not ever get closed. Closing a channel is the best way to signal that a channel doesn't have any more info. Currently, the channel signals that it's done by putting a
:done
value on the channel. I think it would be preferable to just close the channel rather than send an unqualified:done
as a sentinel, but I did not make that change since it would be backwards incompatible.Closing the channel when the stream is finished also makes the channel compatible with existing builtin functions. For example:
The above works after applying the attached change.