Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra tips for running IO #885

Merged
merged 2 commits into from
Jun 13, 2018
Merged

Add extra tips for running IO #885

merged 2 commits into from
Jun 13, 2018

Conversation

pakoito
Copy link
Member

@pakoito pakoito commented Jun 12, 2018

Requested on gitter, it explains why runAsync doesn't start immediately.

@pakoito pakoito requested review from raulraja, JorgeCastilloPrz, nomisRev and a team June 12, 2018 22:43
@@ -40,6 +42,8 @@ All exceptions that would happen on the function parameter are automatically cap

It runs the current `IO` asynchronously, calling the callback parameter on completion and returning its result.

The operation will not yield a result immediately; ultimately to start running the suspended computation you have to evaluate that new instance using an unsafe operator like `unsafeRunAsync` or `unsafeRunSync` for `IO`.

```kotlin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we are not using ank on these snippets?

Could we perhaps add an additional snippet to accompany the added docs?

val io = IO<Int> { throw RuntimeException("Boom!") }
  .runAsync { result ->
    result.fold({ IO { println("Error") } }, { IO { println(it.toString()) } })
  }

The operation will ...

Copy link
Member Author

@pakoito pakoito Jun 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Async operations fail to execute on Ank. That snippet is right below this paragraph, if you expand the file.

@pakoito pakoito merged commit ea44287 into master Jun 13, 2018
@pakoito pakoito deleted the paco-runningioright branch June 13, 2018 11:49
RawToast pushed a commit to RawToast/kategory that referenced this pull request Jul 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants