From 94bccacb2d3d31fab9c15ee1d1ec1a0bd6bb466d Mon Sep 17 00:00:00 2001 From: Michael Bull Date: Wed, 10 Feb 2021 22:34:44 +0000 Subject: [PATCH] Improve wording in README --- README.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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() }