Skip to content

Instantly share code, notes, and snippets.

@jasdev

jasdev/double_sink_just.swift Secret

Created Apr 30, 2020
Embed
What would you like to do?
Double subscribe a single `Sink` to a `Just` with `print` operator.
let sink = Subscribers.Sink<Int, Never>(
receiveCompletion: { _ in },
receiveValue: { _ in }
)
Just(1)
.print()
.subscribe(sink)
Just(1)
.print()
.subscribe(sink)
/// (1) Output:
/// ```none
/// receive subscription: (Just)
/// request unlimited
/// receive value: (1)
/// receive finished
/// receive subscription: (Just)
/// receive cancel
/// ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment