-
-
Save jasdev/9cade706a68844a00d160042bffce657 to your computer and use it in GitHub Desktop.
Proper `.cher` implementation.
This file contains 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
extension Publisher { | |
func cher() -> Publishers.Autoconnect< | |
Publishers.Multicast< | |
Self, | |
PassthroughSubject<Output, Failure> | |
> | |
> { | |
multicast(PassthroughSubject.init) | |
.autoconnect() | |
} | |
} | |
var subscriptions = Set<AnyCancellable>() | |
Just(1) | |
.cher() | |
.sink { print($0) } | |
.store(in: &subscriptions) | |
/// (1) We’re back in `print`ing action—a `1` is logged. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment