Skip to content

Instantly share code, notes, and snippets.

@aronbalog
Last active July 26, 2019 19:27
Show Gist options
  • Save aronbalog/9eb83c19c795de23194b3a5e415166ef to your computer and use it in GitHub Desktop.
Save aronbalog/9eb83c19c795de23194b3a5e415166ef to your computer and use it in GitHub Desktop.
import CoreNavigation
struct PersonProfile: Destination {
typealias ViewControllerType = PersonProfileViewController
let personId: String
init(_ personId: String) {
self.personId = personId
}
var parameters: [String : Any]? {
return [
"personId": personId
]
}
static func resolve(context: Context<PersonProfile>) {
guard let personId = context.parameters?["personId"] as? String else {
// cancel navigation with some error
context.cancel(error: NavigationError.Destination.notFound)
}
// fetch person
fetchPerson(id: personId, completion: { (person: Person) in
// continue to navigation
context.complete(data: person)
}, failure: { (error: Error) in
// cancel navigation with some error
context.cancel(error: error)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment