Resource
public struct Resource<Model>Resource describes a remote resource of generic type.
The type can be fetched via HTTP(S) and parsed into the coresponding model object.
Example:
let request: URLRequest = //
let resource: Resource<String?> = Resource(request: request, parse: { data in
   String(data: data, encoding: .utf8)
})
- 
                  
                  The request to fetch the resource remote payload DeclarationSwift public let request: URLRequest
- 
                  
                  Parses data into given model. DeclarationSwift public let parse: (_ data: Data) throws -> Model
- 
                  
                  Creates a type safe resource, which can be used to fetch it with NetworkServiceDeclarationSwift public init(request: URLRequest, parse: @escaping (Data) throws -> Model)ParametersrequestThe request to get the remote data payload parseParses data fetched with the request into given Model 
- 
                  
                  Creates an instace of Resource where the result type is Decodableand can be decoded with the given decoderDeclarationSwift public init(request: URLRequest, decoder: JSONDecoder)ParametersrequestThe request to get the remote data payload decodera decoder which can decode the payload into the model type 
- 
                  
                  This lets one inspect the data payload before data gets parsed. let resource: Resource<Train> = // resource.inspectData { data in print(String(bytes: data, encoding: .utf8)) }DeclarationSwift public func inspectData(_ inspector: @escaping (Data) -> Void) -> Resource<Model>Parametersinspectorclosure which gets passed the data Return Valuea new resource which gets instepcted before parsing 
- 
                  
                  Maps a resource result to a different resource. This is useful when you have result of R which contains T and your API request a resource of T, DeclarationSwift public func map<T>(transform: @escaping (Model) throws -> T) -> Resource<T>Parameterstransformtransforms the original result of the resource Return Valuethe transformed resource 
 View on GitHub
View on GitHub Resource Structure Reference
        Resource Structure Reference