Requests
-
An API request. Provides notification hooks about the status of the request, and allows cancellation.
Note that this represents only a single request, whereas
ResourceObserver
s receive notifications about all resource load requests, no matter who initiated them. Note also that these hooks are available for all requests, whereasResourceObserver
s only receive notifications about changes triggered byload()
,loadIfNeeded()
, andoverrideLocalData(...)
.Request
guarantees that it will call any given callback at most one time.Callbacks are always called on the main thread.
Note
There is no race condition between a callback being added and a response arriving. If you add a callback after the response has already arrived, the callback is still called as usual. In other words, when attaching a hook, you do not need to worry about where the request is in its lifecycle. Except for how soon it’s called, your hook will see the same behavior regardless of whether the request has not started yet, is in progress, or is completed.Declaration
Swift
public protocol Request : AnyObject
-
Declaration
Swift
public enum RequestMethod : String
-
Indicates whether a
Request
has been started, and whether it has completed.See also
Request.state
Declaration
Swift
public enum RequestState
-
Information about a failed resource request.
Siesta can encounter errors from many possible sources, including:
- client-side encoding / request creation issues,
- network connectivity problems,
- protocol issues (e.g. certificate problems),
- server errors (404, 500, etc.), and
- client-side parsing and entity validation failures.
RequestError
presents all these errors in a uniform structure. Several properties preserve diagnostic information, which you can use to intercept specific known errors, but these diagnostic properties are all optional. They are not even mutually exclusive: Siesta errors do not break cleanly into HTTP-based vs. Error / NSError-based, for example, because network implementations may sometimes provide both an underlyingError
and an HTTP diagnostic.The one ironclad guarantee that
See moreRequestError
makes is the presence of auserMessage
.Declaration
-
The outcome of a network request: either success (with an entity representing the resource’s current state), or failure (with an error).
See moreDeclaration
Swift
public enum Response : CustomStringConvertible
-
Declaration
Swift
public struct ResponseInfo