Last active
July 26, 2019 19:27
-
-
Save aronbalog/9eb83c19c795de23194b3a5e415166ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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