Skip to content

Latest commit

 

History

History
32 lines (21 loc) · 879 Bytes

Basics.md

File metadata and controls

32 lines (21 loc) · 879 Bytes

Basics

While Model is something represented by a table in your database, RestKit introduces such thing as ResourceModel. ResourceModel is a wrap over the Model that is returned from backend API as a response and consumed by backend API as a request.

At Rest-Kit, Resource is separated into Output:

protocol ResourceOutputModel: Content {
    associatedtype Model: Fields

    init(_: Model)
}

and Input:

protocol ResourceUpdateModel: Content, Validatable {
    associatedtype Model: Fields

    func update(_: Model) -> Model
}

protocol ResourcePatchModel: Content, Validatable {
    associatedtype Model: Fields

    func patch(_: Model) -> Model
}

Input and Output Resources provide managable interface for the models. Each model can have as many possible inputs and outputs as you wish, though it's better not to.