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 contramap method to Callback #384

Merged
merged 2 commits into from Jul 17, 2017

Conversation

Projects
None yet
2 participants
@wogan
Contributor

wogan commented Jul 3, 2017

Allows you to perform transformations on callback based APIs. Using contramap on a callback means you don't need to provide an ExecutionContext to map on a Future.

Example:

def example: Future[Result] = {
    val promise: Promise[Result] = Promise[Result]()
    val callback: Callback[ApiResult] =
         Callback.fromPromise(promise).contramap { apiResult: ApiResult =>
             Result.fromApiResult(apiResult)
         }
    api.method("request data", callback)
    promise.future
}
@alexandru

This comment has been minimized.

Member

alexandru commented Jul 17, 2017

Thanks @wogan, will merge after I fix the build, which is currently failing for some reason.

@alexandru alexandru merged commit be9602c into monix:master Jul 17, 2017

1 check failed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details

@alexandru alexandru added this to the 3.0.0 milestone Jan 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment