Created
May 30, 2025 07:08
-
-
Save jacobsapps/5871d0ddf60bd8a7169a015bc71190a3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| webSocketService.publisher | |
| .buffer(size: 1, prefetch: .keepFull, whenFull: .dropOldest) | |
| .compactMap { data -> AuctionBid? in | |
| try? decoder.decode(AuctionBid.self, from: data) | |
| } | |
| .scan([]) { (history: [AuctionBid], newBid) in | |
| history + [newBid] | |
| } | |
| .receive(on: RunLoop.main) | |
| .sink(receiveCompletion: { print($0) }, | |
| receiveValue: { bids in | |
| withAnimation { | |
| bidHistory = bids | |
| highestBid = bids.last | |
| timeRemaining = bids.last?.timeRemaining ?? 0 | |
| } | |
| }) | |
| .store(in: &cancellables) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment