Optional state and split view controllers

I'm building an app using UIKit. The root view controller is a split view controller. Whenever the user selects something in the sidebar an optional state is set and a detail view controller is displayed as a result of that thanks to this snippet:

    store.scope(state: \.listStateView, action: { .selectedListAction($0) })
      .ifLet { [weak self] scopedStore in
        guard let self = self else { return }
        self.splitController.showDetailViewController(ListViewController(store: scopedStore), sender: self)
      .store(in: &cancellables)

This works pretty well on an iPhone. However, on an iPad, since the detail view is never popped the listStateView property is never nilled out. So when the user taps a different item in the sidebar that substate is just updated. Everything's hooked up in a way that makes that work, but the collection view in the detail view is updated with an animation.

I can solve this by checking identifiers and making sure that I apply the new data source snapshot without animations. But if I wanted to trigger the scoping again to create a brand new view controller, how would I go about that without introducing delays and run loop skips? Is it possible?

Terms of Service

Privacy Policy

Cookie Policy