Use .from(OtherDestinationStep) only with same context?
ArtSumin opened this issue · 1 comments
I want to use a view controllers chain in one navigation controller. I have to use the same context for each view controller on the stack. How to be in this case? Use type Any for context and later convert to the desired type?
You can use Any
or Dictionary
or any other type. But unless your navigation is completely dynamic I would strongly advice agains it. Most likely with a wider view on your business task you may come with the right answer.
I'll give an example that helps some people.
Lets say you have a booking app that has a home screen, a hotel screen and the room screen.
- Home screen doesn need any data to display itself.
- Hotel screen needs a hotel ID
- Room screen needs a hotel ID and a room ID
Chain will look like:
Home
-> Hotel
-> Room
So the correct way to navigate to all of this screen will be to descibe the common context for the hotel and a room screen
Something like:
struct BookingContext {
let hotelId: String
let roomId: String?
}
And keep the Home
context type as Any?
as home can be presented without any context.
With such configuration you will be able to navigate to any of this screens