-
Notifications
You must be signed in to change notification settings - Fork 18
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
What's the best way to cancel things? #22
Comments
Depends on what you want to do with any existing / waiting data. |
Yeah, I think so, so that if something is waiting on a value from Is something like that already doable? I'm currently working on a way to organize animation states and transitions, and I'd like for them to be cancellable. I know I can just use plain promises, and reject things with "sentinel" values, but as you imagine, doing it that way would get messy. I'm wondering if there's a clean way of organizing this with channels. I know I can send anything I want through a channel, so I can design my own "sentinel" values to tell the receiving end what's going on. Let me play with it and see what I come up with using the existing public API |
My gut is telling me to suggest using The call to |
In my case, I've got a single process taking, so I ended up just sending
false when complete, which made the conditional check less verbose on the
taking side.
What if we have a channel, and we'd like a varying and unknown number of
takers to take on the receiving side?
F.e., something like this: 10 receivers take() and they all wait... Sender
put()s one value then all receivers resolve on the value.... Now 6
receivers take() and wait... Send put()s another single value.
Is each receiver supposed to be responsible for forking the channel in that
case?
…On Feb 26, 2018 1:41 PM, "dvlsg" ***@***.***> wrote:
My gut is telling me to suggest using Channel#close() and then keep an
eye out for that Channel.DONE symbol in any Channel#take() calls, but you
won't be able to re-use the channel, in that case. Right now, you'd have to
set up another one.
The call to take() will resolve, so you'd still have to wait for it (sort
of), but it won't wait for new values to come into the channel -- all
outstandings takes should resolve with the Channel.DONE value ASAP, even
if there are a bunch queued up.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#22 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AASKzpA58ldDKWnAepwJPgnmbCuB7jPtks5tYyUBgaJpZM4QV2d9>
.
|
Probably the best way of doing it, yes. Shouldn't be too difficult to make an api which appends / returns a newly piped channel when a new consumer shows up. I think |
What's the recommended way to make cancellable sort of scenarios in an application with async-csp? Basically, suppose we've got any number of things waiting for output from a channel, but the user clicks a "cancel" button. Are there any recommended patterns for cancellation?
The text was updated successfully, but these errors were encountered: