Skip to content

Commit

Permalink
wording
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlesMcD committed Jan 14, 2025
1 parent c2f04e5 commit b930239
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class Promise<T> 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
Expand All @@ -60,22 +63,22 @@ class Promise<T> internal constructor(
.subscribe(
internalCancellableManager,
onNext = { value ->
if (!onParentCancellation.isCancelled) {
if (!isParentCancellableCancelled) {
result.value = value
result.complete()

onResultReceived()
}
},
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
}
Expand Down

0 comments on commit b930239

Please sign in to comment.