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

feat: implement Source.future operator #32

Merged
merged 1 commit into from
Nov 2, 2023
Merged

feat: implement Source.future operator #32

merged 1 commit into from
Nov 2, 2023

Conversation

geminicaprograms
Copy link
Contributor

@geminicaprograms geminicaprograms commented Oct 31, 2023

Creates a source that emits a single value when Future completes or fails otherwise.

Notes:

  • when Future fails with scala.concurrent.ExecutionException then its cause is returned as source failure.
  • the input Future cannot be null
  • the Future completion is performed on the provided ExecutionContext

Examples:

  Source .future(Future.failed(new RuntimeException("future failed")))
    .receive()                               // ChannelClosed.Error(Some(java.lang.RuntimeException: future failed))
  Source.future(Future.successful(1)).toList // List(1)

Creates a source that emits a single value when Future completes or fails
otherwise.

Notes:
* when Future fails with `scala.concurrent.ExecutionException` then
  its cause is returned as source failure
* the `Future` completion is performed on the provided
  `ExecutionContext`

Examples:

  Source
    .future(Future.failed(new RuntimeException("future failed")))
    .receive()                               // ChannelClosed.Error(Some(java.lang.RuntimeException: future failed))
  Source.future(Future.successful(1)).toList // List(1)
@adamw adamw merged commit efd3b9a into master Nov 2, 2023
4 checks passed
@geminicaprograms geminicaprograms deleted the feat_future branch November 2, 2023 10:34
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.

4 participants