-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IDEA: add a onFinally arg in hold #65
Comments
Very nice idea! |
I was understanding that finally was executed at the very end. This needs some tests to be sure.
Because in chrome execute you were closing with finally and this is what gave me the idea. But are finally and on.exit the same if finally is the last thing executed ? Seems like it is ... 🤔 |
Sorry, I was 100% wrong. library(promises)
promise <- promise_resolve(1)
then(
promise,
onFulfilled = function(value) {
cat("onfulfilled\n")
}
) %>%
finally(onFinally = ~ stop("something went wrong in finalizer")) If you run this script, you get an unhandled rejected promise. |
From the previous example, I think the safest way to use promises::then(
promises::finally(promise, onFinally = fun),
onFulfilled = function(value) {
state$pending <- FALSE
state$fulfilled <- TRUE
state$value <- value
},
onRejected = function(error) {
state$pending <- FALSE
state$fulfilled <- FALSE
state$reason <- error
}
) The main difference with |
The second choice is maybe simpler ? |
I agree: saying that the |
That would be passed to
promises::finally
to execute before returning the promise valueI have thought about that while working on
chrome_execute
thinking that chrome could be closed at the very end withThoughts ?
The text was updated successfully, but these errors were encountered: