Last active
February 7, 2021 03:22
-
-
Save jasdev/f406332b87651f1919dfb8aec9c34f89 to your computer and use it in GitHub Desktop.
An initial sketch of Publisher.pairwiseWithDuplicatedStart.
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 CombineExt | |
let upstream = (1...2) | |
.publisher | |
.share() | |
let cancellable = upstream | |
.first() | |
.flatMap { first in | |
upstream | |
.prepend(first, first) | |
} | |
.pairwise() | |
.sink(receiveValue: { print($0) }) | |
// Outputs: | |
// ``` | |
// (1, 1) | |
// (1, 1) | |
// (1, 2) | |
// ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment