diff --git a/README.md b/README.md index 1c66396..2bd8dfe 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,8 @@ resources on the topic of monad comprehensions. #### Coroutine Support -Use of coroutines within a `binding` block requires an additional dependency: +Use of suspending functions within a `binding` block requires an additional +dependency: ```kotlin dependencies { @@ -157,15 +158,20 @@ dependencies { } ``` -This allows for asynchronous binds to operate so that if a bind were to fail, -the binding block will return with the first failing async result: +The coroutine implementation of `binding` has been designed so that the first +call to `bind()` that fails will cancel all child coroutines within the current +coroutine scope. + +The example below demonstrates a computationally expensive function that takes +five milliseconds to compute being eagerly cancelled as soon as a smaller +function fails in just one millisecond: + ```kotlin - suspend fun failsIn5ms(): Result { ... } suspend fun failsIn1ms(): Result { ... } -runBlocking{ +runBlocking { val result = binding { val x = async { failsIn5ms().bind() } val y = async { failsIn1ms().bind() }