262588213843476 · Gist

Demonstrating bug with `cherReplayingLatest`.

var subscriptions = Set<AnyCancellable>()
let cheredWithReplay = Just(1)
.cherReplayingLatest()
cheredWithReplay
.sink(
receiveCompletion: { print("First completion: \($0)") },
receiveValue: { print("First sink: \($0)") }
)
.store(in: &subscriptions)
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3)) { /// (1) Queuing up another
/// subscription, three seconds later.
cheredWithReplay
.sink(
receiveCompletion: { print("Second completion: \($0)") },
receiveValue: { print("Second sink: \($0)") }
)
.store(in: &subscriptions)
}
/// (2) Console output:
/// ```
/// First sink: 1
/// First completion: finished
/// Second completion: finished
/// ```

Read the original on gist.github.com ↗