API polling and timeout
问题 I have a polling use-case where: I want to call an API that, based on business logic, returns numbers(1-10) or error (network issue/ exception in API etc..) instantly (1.5-2 sec). If the API returns an error (network issue/ exception in API etc..) then I want to unsubscribe the polling and display error. If the API returns success, I want to check the return value and un-subscribe(if the return value is 5) or keep the polling going. I want to call API every 5 sec. I want to keep the max time