elizarov
01/30/2018, 12:46 PMsuspend
when you expect their implementation to be non-blocking to the invoker thread (aka “asynchronous”). So, if I read your API and see interface Foo { fun doSomethingNetworkRelated() }
, then I immediately see that doSomethingNetworkRelated
is going to block my thread while it does its network stuff. However, if I see interface Foo { suspend fun doSomethingNetworkRelated() }
then I assume that implementation is non-blocking and can be safely used, for example, from my UI thread or from other precious event-loop.