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 ResourceObservers receive notifications about all resource load requests, no matter who initiated them. Note also that these hooks are available for all requests, whereas ResourceObservers only receive notifications about changes triggered by load(), loadIfNeeded(), and overrideLocalData(...).

    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.
    See more

    Declaration

    Swift

    public protocol Request : AnyObject
  • HTTP request methods.

    See the various Resource.request(...) methods.

    See more

    Declaration

    Swift

    public enum RequestMethod : String
  • Indicates whether a Request has been started, and whether it has completed.

    See also

    Request.state
    See more

    Declaration

    Swift

    public enum RequestState
  • The outcome of a network request: either success (with an entity representing the resource’s current state), or failure (with an error).

    See more

    Declaration

    Swift

    public enum Response : CustomStringConvertible
  • A Response, plus metadata about the nature of the response.

    See more

    Declaration

    Swift

    public struct ResponseInfo
  • 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 underlying Error and an HTTP diagnostic.

    The one ironclad guarantee that RequestError makes is the presence of a userMessage.

    See more

    Declaration

    Swift

    public struct RequestError : Error