Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
`RandomNumberViewModel` pings.
let viewModel = RandomNumberViewModel()
viewModel.randomNumberPing.send()
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3)) { /// (1) Adding some delay, to disambiguate
/// `print` operator logs.
viewModel.randomNumberPing.send()
}
/// (2) Giving the above a few (or many) runs will hint at what’s wrong. We’ll either see one (or two) received
/// value events with even integers or, a _single_ error event. That is, if the first request errors out,
/// we never attempt the second.
///
/// Here’s some sample output from three runs,
///
/// ```
///
/// receive value: (187746)
/// receive error: (failedRequest)
/// ```
///
/// ```
///
/// receive error: (failedRequest)
/// ```
///
/// ```
///
/// receive value: (194794)
/// receive value: (157570)
/// ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment