mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
pr suggestions and implemented a simpler way to clear the route, that always brings back to the initial coordinator
This commit is contained in:
@@ -13,6 +13,7 @@ import SwiftState
|
||||
protocol StateMachineFactoryProtocol {
|
||||
func makeUserSessionFlowStateMachine(state: UserSessionFlowCoordinator.State) -> StateMachine<UserSessionFlowCoordinator.State, UserSessionFlowCoordinator.Event>
|
||||
func makeChatsFlowStateMachine() -> ChatsFlowCoordinatorStateMachine
|
||||
func makeMembersFlowStateMachine(state: RoomMembersFlowCoordinator.State) -> StateMachine<RoomMembersFlowCoordinator.State, RoomMembersFlowCoordinator.Event>
|
||||
}
|
||||
|
||||
struct StateMachineFactory: StateMachineFactoryProtocol {
|
||||
@@ -23,6 +24,10 @@ struct StateMachineFactory: StateMachineFactoryProtocol {
|
||||
func makeChatsFlowStateMachine() -> ChatsFlowCoordinatorStateMachine {
|
||||
.init()
|
||||
}
|
||||
|
||||
func makeMembersFlowStateMachine(state: RoomMembersFlowCoordinator.State) -> StateMachine<RoomMembersFlowCoordinator.State, RoomMembersFlowCoordinator.Event> {
|
||||
.init(state: state)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: For testing
|
||||
@@ -49,4 +54,14 @@ class PublishedStateMachineFactory: StateMachineFactoryProtocol {
|
||||
stateMachine.addTransitionHandler { [weak self] in self?.chatsFlowStatePublisher.send($0.toState) }
|
||||
return stateMachine
|
||||
}
|
||||
|
||||
// MARK: MembersFlowCoordinator
|
||||
|
||||
let membersFlowStatePublisher = PassthroughSubject<RoomMembersFlowCoordinator.State, Never>()
|
||||
|
||||
func makeMembersFlowStateMachine(state: RoomMembersFlowCoordinator.State) -> StateMachine<RoomMembersFlowCoordinator.State, RoomMembersFlowCoordinator.Event> {
|
||||
let stateMachine = baseFactory.makeMembersFlowStateMachine(state: state)
|
||||
stateMachine.addAnyHandler(.any => .any) { [weak self] in self?.membersFlowStatePublisher.send($0.toState) }
|
||||
return stateMachine
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user