18 lines
519 B
Swift
18 lines
519 B
Swift
|
import Combine
|
||
|
import Foundation
|
||
|
|
||
|
final class MessagesMiddleware {
|
||
|
static let shared = MessagesMiddleware()
|
||
|
|
||
|
func middleware(state _: AppState, action: AppAction) -> AnyPublisher<AppAction, Never> {
|
||
|
switch action {
|
||
|
case .messagesAction(.currentConversationMessagesUpdated(let messages)):
|
||
|
return Just(.conversationAction(.messagesUpdated(messages: messages)))
|
||
|
.eraseToAnyPublisher()
|
||
|
|
||
|
default:
|
||
|
return Empty().eraseToAnyPublisher()
|
||
|
}
|
||
|
}
|
||
|
}
|