Last active
July 11, 2021 13:35
-
-
Save layoutSubviews/4f847b65a9935a20f445ec73f8e00651 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
import Combine | |
import Foundation | |
let c = Publishers | |
.CombineLatest( | |
Just(true) | |
.delay(for: .seconds(0.5), scheduler: DispatchQueue(label: "A")) | |
.prepend(false), | |
Just(true) | |
.delay(for: .seconds(1), scheduler: DispatchQueue(label: "B")) | |
.prepend(false) | |
) | |
.print() | |
.dropFirst() | |
.sink { _ in | |
sleep(1) // Simulating some heavy computation, making "B" emit while "A" is still being processed | |
} | |
// Expecting a sequence of (false, false), (true, false), (true, true), finished | |
// Getting a sequence of (false, false), (true, false), finished 😱 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment