mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-29 20:56:57 +02:00
Made StateStoreViewModel state mutable and removed the reducer for all the features using it.
This commit is contained in:
committed by
Stefan Ceriu
parent
fc9e95aee8
commit
313b05485a
-5
@@ -32,11 +32,6 @@ enum TemplateRoomListCoordinatorAction {
|
||||
|
||||
// MARK: - View model
|
||||
|
||||
/// Actions to be performed on the `ViewModel` State
|
||||
enum TemplateRoomListStateAction {
|
||||
case updateRooms([TemplateRoomListRoom])
|
||||
}
|
||||
|
||||
/// Actions sent by the`ViewModel` to the `Coordinator`.
|
||||
enum TemplateRoomListViewModelAction {
|
||||
case didSelectRoom(String)
|
||||
|
||||
+7
-12
@@ -19,7 +19,7 @@ import Combine
|
||||
|
||||
@available(iOS 14, *)
|
||||
typealias TemplateRoomListViewModelType = StateStoreViewModel<TemplateRoomListViewState,
|
||||
TemplateRoomListStateAction,
|
||||
Never,
|
||||
TemplateRoomListViewAction>
|
||||
@available(iOS 14.0, *)
|
||||
class TemplateRoomListViewModel: TemplateRoomListViewModelType, TemplateRoomListViewModelProtocol {
|
||||
@@ -47,10 +47,12 @@ class TemplateRoomListViewModel: TemplateRoomListViewModelType, TemplateRoomList
|
||||
}
|
||||
|
||||
private func startObservingRooms() {
|
||||
let roomsUpdatePublisher = templateRoomListService.roomsSubject
|
||||
.map(TemplateRoomListStateAction.updateRooms)
|
||||
.eraseToAnyPublisher()
|
||||
dispatch(actionPublisher: roomsUpdatePublisher)
|
||||
templateRoomListService
|
||||
.roomsSubject
|
||||
.sink { [weak self] rooms in
|
||||
self?.state.rooms = rooms
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
@@ -64,13 +66,6 @@ class TemplateRoomListViewModel: TemplateRoomListViewModelType, TemplateRoomList
|
||||
}
|
||||
}
|
||||
|
||||
override class func reducer(state: inout TemplateRoomListViewState, action: TemplateRoomListStateAction) {
|
||||
switch action {
|
||||
case .updateRooms(let rooms):
|
||||
state.rooms = rooms
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func done() {
|
||||
|
||||
Reference in New Issue
Block a user