17 lines
463 B
Swift
17 lines
463 B
Swift
|
import Combine
|
||
|
|
||
|
final class ChatsMiddleware {
|
||
|
static let shared = ChatsMiddleware()
|
||
|
|
||
|
func middleware(state _: AppState, action: AppAction) -> AnyPublisher<AppAction, Never> {
|
||
|
switch action {
|
||
|
case .databaseAction(.storedChatsLoaded(let chats)):
|
||
|
return Just(.chatsAction(.chatsListUpdated(chats: chats)))
|
||
|
.eraseToAnyPublisher()
|
||
|
|
||
|
default:
|
||
|
return Empty().eraseToAnyPublisher()
|
||
|
}
|
||
|
}
|
||
|
}
|