Created
June 19, 2019 12:54
-
-
Save laevandus/c147cbf496eaf11d38ac476bd714f1dc to your computer and use it in GitHub Desktop.
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
struct Session { | |
let messageFeed = PassthroughSubject<Message, Never>() | |
func send(_ message: Message) { | |
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) { | |
self.messageFeed.send(message) | |
self.simulateReceivingMessages() | |
} | |
} | |
private func simulateReceivingMessages() { | |
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(200)) { | |
let receivedMessage = Message(sender: "Person B", text: UUID().uuidString) | |
self.messageFeed.send(receivedMessage) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment