This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class Conversation: ObservableObject { | |
private let session = Session() | |
private var messageSubscriber: AnyCancellable? | |
init() { | |
messageSubscriber = session.messageFeed.sink { [weak self] (receivedMessage) in | |
self?.messages.append(receivedMessage) | |
} | |
} | |
@Published private(set) var messages = [Message]() | |
func send(_ message: Message) { | |
session.send(message) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment