Just thinking out loud to see if anyone has any id...
# random
c
Just thinking out loud to see if anyone has any ideas on a problem I have to tackle later this week. I have a callback that happens where I take some data that gets handed to me, and pass it to a third party service, and typically the third party service responds quickly where I cancel the initial callback. But now... the initial callback got a lot faster (like every 100ms) so I send stuff to the third party server (which is fine), but then even though I get a success... I'll get like 3 more successes after that. So... I basically have
Copy code
callback.onCalledBack {
 if (noResponseHasComeBackAsSuccessfulYet) {
    makeCallToThirdParty(it)
  }
}
so basically, the fact that I use a boolean is kinda bad because the callback happens a bunch of times now. The solution? Flows! But I suck at flows. What should I use? StateFlow, just a regular flow? I think I want this to initially just work as a queue where I don't send anything to the third party if there is already something in flight. Long term, it wouldn't be bad to just send a bunch of calls to the thirdParty (its cheap) and the first one back wins. idk. Thinking out loud. Thoughts anyone? I think I just want this
Copy code
callback.onCalledBack {
    addToQueue(it)
 }
and then something just subscribes to the queue and handles things procedurally
rubber duck don't think a queue would actually work. i actually get failures like half the time, and so actually sending the events over as they come is sorta important. but i just want to kill off the 3rd party service work/throw away the result if I already got a result. hmmmmm
e
c
ah. idk why i didn't think about that. so just take the initial callback based stuff and convert that to a flow itself instead of trying to put in some intermediate flow data type and adding to it. 🤯