import Foundation
import Combine

final class TopObserverMiddleware {
    private let jid: JID
    private let callback: (XMPPClientUpdateMsg) -> Void

    init(jid: JID, callback: @escaping (XMPPClientUpdateMsg) -> Void) {
        self.jid = jid
        self.callback = callback
    }

    func middleware(state: ClientState, action: ClientAction) -> AnyPublisher<ClientAction, Never> {
        callback((state: state, action: action))
        return Empty().eraseToAnyPublisher()
    }
}
