Skip to content

Instantly share code, notes, and snippets.

@layoutSubviews
Last active July 11, 2021 13:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save layoutSubviews/4f847b65a9935a20f445ec73f8e00651 to your computer and use it in GitHub Desktop.
Save layoutSubviews/4f847b65a9935a20f445ec73f8e00651 to your computer and use it in GitHub Desktop.
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