Wraps an async callback with reactive isLoading/apiData/hasError state.
Error contract (Pattern A of the error-handling policy): if callback
throws, hasError is set to true and the failure is wrapped in an
ApiCallError (the original error is preserved on .cause). onError
(when provided) is invoked with that ApiCallError, and it is then
rethrown from callApi unless rethrow: false was passed. A caller that
doesn't pass onError and doesn't set rethrow: false still learns about
the failure - it just has to await/.catch()callApi itself, the same
as it would for any other async function.
Wraps an async callback with reactive isLoading/apiData/hasError state.
Error contract (Pattern A of the error-handling policy): if
callbackthrows,hasErroris set totrueand the failure is wrapped in anApiCallError(the original error is preserved on.cause).onError(when provided) is invoked with thatApiCallError, and it is then rethrown fromcallApiunlessrethrow: falsewas passed. A caller that doesn't passonErrorand doesn't setrethrow: falsestill learns about the failure - it just has toawait/.catch()callApiitself, the same as it would for any other async function.