{"action":"created","issue":{"url":"https://api.github.com/repos/Kotlin/kotlinx.coroutines/issues/30","repository_url":"https://api.github.com/repos/Kotlin/kotlinx.coroutines","labels_url":"https://api.github.com/repos/Kotlin/kotlinx.coroutines/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/Kotlin/kotlinx.coroutines/issues/30/comments","events_url":"https://api.github.com/repos/Kotlin/kotlinx.coroutines/issues/30/events","html_url":"https://github.com/Kotlin/kotlinx.coroutines/issues/30","id":206130094,"number":30,"title":"How to convert a callback to a Deferred on JDK6","user":{"login":"ljani","id":1334470,"avatar_url":"https://avatars.githubusercontent.com/u/1334470?v=3","gravatar_id":"","url":"https://api.github.com/users/ljani","html_url":"https://github.com/ljani","followers_url":"https://api.github.com/users/ljani/followers","following_url":"https://api.github.com/users/ljani/following{/other_user}","gists_url":"https://api.github.com/users/ljani/gists{/gist_id}","starred_url":"https://api.github.com/users/ljani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljani/subscriptions","organizations_url":"https://api.github.com/users/ljani/orgs","repos_url":"https://api.github.com/users/ljani/repos","events_url":"https://api.github.com/users/ljani/events{/privacy}","received_events_url":"https://api.github.com/users/ljani/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-02-08T08:41:39Z","updated_at":"2017-02-08T13:10:05Z","closed_at":"2017-02-08T12:43:53Z","body":"I'm still a little new to Kotlin and especially its coroutines, so pardon me if I'm asking stupid questions.\r\n\r\nCould you provide an example how to interface a third-party library utilizing callbacks with `kotlinx-coroutines-core` with JDK6?\r\n\r\nIf it's currently not possible, could the required functionality be considered to be added?\r\n\r\n`kotlinx-coroutines-jdk8` has `CompletableFuture`, but I'm not able to use JDK8. Another way would be to utilize something like [streamsupport's](https://sourceforge.net/projects/streamsupport/) `streamsupport-cfuture`, but I'd prefer not to add it as a dependency if possible.\r\n\r\nAlso, I could use channels, but if `Deferred` is the recommended way to transfer a single value between coroutines, I'd like to use that.\r\n\r\nLove the work you are doing!"},"comment":{"url":"https://api.github.com/repos/Kotlin/kotlinx.coroutines/issues/comments/278324564","html_url":"https://github.com/Kotlin/kotlinx.coroutines/issues/30#issuecomment-278324564","issue_url":"https://api.github.com/repos/Kotlin/kotlinx.coroutines/issues/30","id":278324564,"user":{"login":"ljani","id":1334470,"avatar_url":"https://avatars.githubusercontent.com/u/1334470?v=3","gravatar_id":"","url":"https://api.github.com/users/ljani","html_url":"https://github.com/ljani","followers_url":"https://api.github.com/users/ljani/followers","following_url":"https://api.github.com/users/ljani/following{/other_user}","gists_url":"https://api.github.com/users/ljani/gists{/gist_id}","starred_url":"https://api.github.com/users/ljani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljani/subscriptions","organizations_url":"https://api.github.com/users/ljani/orgs","repos_url":"https://api.github.com/users/ljani/repos","events_url":"https://api.github.com/users/ljani/events{/privacy}","received_events_url":"https://api.github.com/users/ljani/received_events","type":"User","site_admin":false},"created_at":"2017-02-08T13:10:05Z","updated_at":"2017-02-08T13:10:05Z","body":"Thanks for the answer, the second paragraph is exactly what I was after. TBH, I had viewed that document before, but as a beginner it was a little too heavy reading, so I missed that part.\r\n\r\nSo, if anyone ends up here via eg. Google, [the answer](https://github.com/Kotlin/kotlin-coroutines/blob/dcd9d1246cc76b178ec9a5a706377b7aca345d32/kotlin-coroutines-informal.md#wrapping-callbacks) is:\r\n```kotlin\r\nsuspend fun someLongComputation(params: Params): Result = suspendCoroutine { c ->\r\n    someLongComputation(params) { c.resume(it) }\r\n}\r\n```"}}
{"actor":{"display_login":"ljani"}}