Non-blocking CURLObservable
In our Reddit reader app, we download data from a remote API using PHP's cURL. Even when using its asynchronous callbacks, such as CURLOPT_PROGRESSFUNCTION
, it's important to keep in mind that curl_exec()
is still a blocking call, no matter what options we choose.
This is due to the fact that PHP runs in a single execution thread and when it starts executing curl_exec()
, everything else needs to wait until it finishes. It's true that this method might call some callback functions, but if any of them got stuck, for example, in an infinite loop, the curl_exec()
function would never end.
This has serious implications for the actual responsiveness of our Reddit reader. While CURLObservable
is downloading data, it doesn't respond to any user input, which is probably not what we want.
When we talked about IntervalObservable
and how it's able to keep the desired interval very precisely, we didn't mention that this is, in fact, a type of situation it can't handle.
Let's make...