twitchEmoteImpl.getChannelEmotes(oAuthToken,clientId,broadcasterId).mapWithRetry(action={// result is the result from getChannelEmotes()// if you wanted to do any manipulation to the // request you would do it hereresult->result},predicate={result,attempt->valrepeatResult=resultisResponse.Failure&&attempt<3repeatResult}).collect{// do what you would normally do once a flow is emitted }
result -> result represents the code not doing any sort of manipulation of the result emitted from the flow
Why use this?
There are times when the request fails and the best solution is to simply make another request. Instead of forcing your user to manually make another request. We can implement this function that will automatically make 3 requests if it fails. We will not inform the users of the extra requests. Instead they should only be informed after the 3 failed attempts
However, be aware that we should not do this on every failed request. On requests that fail due to authentication or no available network errors, we should avoid making multiple requests and simply inform the user of the failed request.
Conclusion
Thank you for taking the time out of your day to read this blog post of mine. If you have any questions or concerns please comment below or reach out to me on Twitter.
Top comments (0)
Subscribe
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)