April 2017
Intermediate to advanced
316 pages
9h 33m
English
Obviously, we can use the Todo model we have used in our backend example, but we want to make our frontend application as functional as possible. There is a functional JSON parsing library named Argo that we can leverage. Let's define our Todo model with Argo:
import Argo import Curry import Runes enum TodoFilter: Int { case all case active case completed case notSyncedWithBackend case selected } struct Todo { let todoId: Int let name: String let description: String let notes: String? let completed: Bool let synced: Bool let selected: Bool? } extension Todo: Decodable { static func decode(_ json: JSON) -> Decoded<Todo> { return curry(Todo.init) <^> json <| "todoId" <*> json <| "name" <*> json <| "description" <*> ...Read now
Unlock full access