Is there any way to suspend until some predicate is met, other than like a while loop?
z
Zach Klippenstein (he/him) [MOD]
06/04/2020, 12:20 AM
By what mechanism does the value of the predicate change? Is there some callback or other notification? There are lots of integrations with existing reactive libraries. (also see the #C1CFAFJSK channel)
a
Andrew
06/04/2020, 12:26 AM
Oops I missed that channel; the predicate is being changed by events recieved from the ktor websocket
z
Zach Klippenstein (he/him) [MOD]
06/04/2020, 1:12 AM
What i meant was, how can you tell that the predicate’s value will have changed? Is there a callback or some other reactive signal, or do you have to poll the value?
a
Andrew
06/04/2020, 1:17 AM
I'm just polling it
z
Zach Klippenstein (he/him) [MOD]
06/04/2020, 1:19 AM
Then yea, use a while loop. But also make sure to yield, which both ensures you participate in cooperative cancellation and allows other coroutines to run.