WebServiceNetworkInterface

@objc
public protocol WebServiceNetworkInterface : AnyObject

WebServiceNetworkInterface: A protocol which lets any object become a bridge between a webservice and the internet. Instances of Swifty conform to this protocol by default

Conformance to this only requires the implementation of one method: loadResource(resource: completion:)

  • Implement this method to tell a WebService what to do when .load() is called on it’s NetworkResource. The NetworkResource on which the .load() method is called comes in as an argument, and any networking library can be used to fire the resource’s internal request over the network, create a NetworkResponse from the actual response, and passed into the completion closure.

    Declaration

    Swift

    func loadResource(resource: NetworkResource, completion: @escaping (NetworkResponse) -> Void)

    Parameters

    resource

    NetworkResource

    completion

    The completion block which expects a NetworkResponse for the resource that was passed in.