I see that ktor-client-ios has cancelation handler...
# reaktive
d
I see that ktor-client-ios has cancelation handler https://github.com/ktorio/ktor/blob/master/ktor-client/ktor-client-ios/darwin/src/io/ktor/client/engine/ios/IosClientEngine.kt Will it work with coroutine cancelation ? I mean if we wrap it by
Copy code
singleFromCoroutine
and on dispose it will be canceled ?
a
It should work, but be careful with freezing. I suppose freezing the Disposable (and so Job) will eventually freeze Ktor things and it may crash. Also I think this can only work with mt coroutines and the new Reaktive
nmtc
version of the
coroutines-interop
module.
d
I use Reaktive 
nmtc
and mt coroutines but dont receive cancelation =( Probably I am missing something
a
The coroutine itself should be cancelled. There are tests for this case, but you could check manualy as well. So if the corotuine is cancelled, then it is probably a question to Ktor. What Reaktive essentially does is:
Copy code
GlobalScope
        .launch(Dispatchers.Unconfined) {
            try {
                onSuccess(block())
            } catch (ignored: CancellationException) {
            } catch (e: Throwable) {
                onError(e)
            }
        }
        .asDisposable()
So it lounches a coroutine and uses its Job for cancellation.
How do you expect to "receive cancellation"?
d
Sorry it was my fault it works fine and NSURLSession request canceled on dispose of subscription
👍 1
@Arkadii Ivanov thank you for mt coroutines interop support😃
🎉 2