From b9302399b40758819d03313255f8db84d70b2912 Mon Sep 17 00:00:00 2001 From: Charles MacDuff Date: Tue, 14 Jan 2025 16:59:07 -0500 Subject: [PATCH] wording --- .../mirego/trikot/streams/reactive/promise/Promise.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/trikot-streams/streams/src/commonMain/kotlin/com/mirego/trikot/streams/reactive/promise/Promise.kt b/trikot-streams/streams/src/commonMain/kotlin/com/mirego/trikot/streams/reactive/promise/Promise.kt index df639905..5d278114 100644 --- a/trikot-streams/streams/src/commonMain/kotlin/com/mirego/trikot/streams/reactive/promise/Promise.kt +++ b/trikot-streams/streams/src/commonMain/kotlin/com/mirego/trikot/streams/reactive/promise/Promise.kt @@ -39,6 +39,9 @@ class Promise internal constructor( } } + private val isParentCancellableCancelled: Boolean + get() = onParentCancellation.isCancelled + /** * When a result is received, we want to make sure we're considered as "cancelled" by the provided cancellableManager if any. * This allows to use `CancellableManager::cleanCancelledChildren` with promises to clean up finished promises @@ -60,7 +63,7 @@ class Promise internal constructor( .subscribe( internalCancellableManager, onNext = { value -> - if (!onParentCancellation.isCancelled) { + if (!isParentCancellableCancelled) { result.value = value result.complete() @@ -68,14 +71,14 @@ class Promise internal constructor( } }, onError = { error -> - if (!onParentCancellation.isCancelled) { + if (!isParentCancellableCancelled) { result.error = error onResultReceived() } }, onCompleted = { - if (!onParentCancellation.isCancelled) { + if (!isParentCancellableCancelled) { if (result.value == null && result.error == null) { result.error = EmptyPromiseException }