What it's the recommended way to support multiple windows without sharing state?

Im currently working with iOS14b4 and Xcode 12b4 and given this basic setup, it can be seen that any change on AppState it's propagated to every scene instances.
So my question is if anybody knows a solution that avoids the unwanted store sharing on the multi window scenario.

struct AppState: Equatable {
  var searchQuery = ""
}

enum AppAction: Equatable {
  case searchQueryChanged(String)
}

struct AppEnvironment {
  var mainQueue: AnySchedulerOf<DispatchQueue>
}

let appReducer = Reducer<AppState, AppAction, AppEnvironment> { state, action, environment in
  switch action {
  case let .searchQueryChanged(query):
    state.searchQuery = query
    return .none
  }
}
struct ContentView: View {
  
  let store: Store<AppState, AppAction>
  
  var body: some View {
    WithViewStore(store) { viewStore in
      TextField(
        "Berlin, Amsterdam, ...",
        text: viewStore.binding(
          get: { $0.searchQuery },
          send: AppAction.searchQueryChanged
        )
      ).padding()
    }
  }
}
@main
struct MultiWindowApp: App {
  
  let store = Store(
    initialState: AppState(),
    reducer: appReducer,
    environment: AppEnvironment(mainQueue: DispatchQueue.main.eraseToAnyScheduler())
  )
  
  var body: some Scene {
    WindowGroup {
      ContentView(store: store)
    }
  }
}
Terms of Service

Privacy Policy

Cookie Policy