-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Awaiting response #26
Labels
Milestone
Comments
emiln
added a commit
that referenced
this issue
May 28, 2015
First shot at implementing awaiting. The last unit test currently fails, but I need help solving it. Hence the broken push.
One corner case: What to do when the the handler returns nil? |
emiln
added a commit
that referenced
this issue
May 31, 2015
emiln
added a commit
that referenced
this issue
May 31, 2015
emiln
added a commit
that referenced
this issue
Jun 1, 2015
This new function emit-with-feedback! is introduced alongside emit! to be explicit about the creation of a feedback channel. This should help newcomers avoid creating a plethora of unused channels that clog up the JVM.
emiln
added a commit
that referenced
this issue
Jun 1, 2015
[#26] Implement emit-with-feedback! to handle awaiting responses from handlers.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
At times it would be great to be able to await a response to some emitted event.
The idea is that any handler for
:do-some-io
can return a non-nil value, and this will be put onto the channel awaited by the function that calledemit! :do-some-io
. This raises a few questions, however, and answering these will be the first task of this story:If multiple functions are awaiting feedback on the same topic, should they all be notified separately by all handlers of the topic?Yes
By the caller of
emit!
; warrants function splitThis is actually a fairly difficult question to answer. It seems unlikely that any one handler will be able to ascertain that no future puts from other handlers could occur to the channel. This leaves the question of whether
emit!
should be split into two functions: one returning an open channel that handlers may communicate over, and one returning nil, opening no channels. I think this might be preferable as it does not risk leaving open channels everywhere, and does not require the caller ofemit!
to diligently close all open, unused feedback channels.Doemit!
andhandle
at this point provide a genuinely simpler and easier interface to the user, or are they really just reinventing core.async poorly?They are warranted
If you wanted to do this without
handle
andemit!
, you'd declare the following once:And the following for every pair of
handle
andemit!
calls:While this is certainly not a big task, I do think
handle
andemit!
provide an easy as well as simple way to deal with this very topic-centric flow.What should happen when a handler returnsnil
? It is not legal to put on a channel.Nothing is put
It is not safe to assume you can close the channel as more puts from other handlers may happen in the future. It is not legal to put
nil
on the channel either, so the sensible and most simple solution is most likely to just don't put anything on at all in this case.The text was updated successfully, but these errors were encountered: