Skip to content
Snippets Groups Projects
Select Git revision
  • eb99e4b70aebd8085f12b8b0d06cb855376252a2
  • main default protected
  • dev protected
  • hotfixes-oct-2022
  • refactor/avatar-cell
  • 1.1.5
  • 1.1.4
  • 1.1.3
  • 1.1
  • 1.0.8
  • 1.0.7
  • 1.0.6
12 results

ChatListController.swift

Blame
  • BackupViewModel.swift 770 B
    import Combine
    import ComposableArchitecture
    
    enum BackupViewState: Equatable {
      case setup
      case config
    }
    
    struct BackupViewModel {
      var setupViewModel: () -> BackupSetupViewModel
      var configViewModel: () -> BackupConfigViewModel
    
      var state: () -> AnyPublisher<BackupViewState, Never>
    }
    
    extension BackupViewModel {
      static func live() -> Self {
        class Context {
          @Dependency(\.backupService) var service
        }
    
        let context = Context()
    
        return .init(
          setupViewModel: { BackupSetupViewModel.live() },
          configViewModel: { BackupConfigViewModel.live() },
          state: {
            context.service.connectedServicesPublisher
              .map { $0.isEmpty ? BackupViewState.setup : .config }
              .eraseToAnyPublisher()
          }
        )
      }
    }