Skip to content

Instantly share code, notes, and snippets.

@jasdev
Last active February 7, 2021 03:22
Show Gist options
  • Save jasdev/f406332b87651f1919dfb8aec9c34f89 to your computer and use it in GitHub Desktop.
Save jasdev/f406332b87651f1919dfb8aec9c34f89 to your computer and use it in GitHub Desktop.
An initial sketch of Publisher.pairwiseWithDuplicatedStart.
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