You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I always define a Router object when a view model's initializing. I want to see my view controllers at Xcode preview, that's why I need to define Router objects at preview state. Is it possible?
The text was updated successfully, but these errors were encountered:
@canbalkaya Interesting idea - what exactly should happen, if a route is triggered? You might for example want to define something like this:
#if targetEnvironment(simulator)privatevarrouterCollection=[ObjectIdentifier: Any]()extensionUnownedRouter{staticfunc preview<RouteType>()->Selfwhere Value ==StrongRouter<RouteType>{letidentifier=ObjectIdentifier(self)
if let existing =routerCollection[identifier]as?StrongRouter<RouteType>{return.init(existing){ $0 }}letcoordinator=BasicViewCoordinator<RouteType>(rootViewController:.init()){ route inprint("prepareTransition(for:)", route)return.none()}letrouter= coordinator.strongRouter
routerCollection[identifier]= router
return.init(router){ $0 }}}#endif
Of course, you could make your previews even more sophisticated by creating the coordinator in a better way, but maybe this idea helps for a start? What do you think about it?
I always define a Router object when a view model's initializing. I want to see my view controllers at Xcode preview, that's why I need to define Router objects at preview state. Is it possible?
The text was updated successfully, but these errors were encountered: