mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
"promise" package was renamed to "promises"
This commit is contained in:
@@ -72,7 +72,7 @@ Imports:
|
||||
htmltools (>= 0.3.5),
|
||||
R6 (>= 2.0),
|
||||
sourcetools,
|
||||
promise,
|
||||
promises,
|
||||
tools
|
||||
Suggests:
|
||||
datasets,
|
||||
|
||||
@@ -4,7 +4,7 @@ call_async <- function(func, ..., args = NULL) {
|
||||
args <- list(...)
|
||||
rx <- callr::r_bg(rlang::as_function(func), args)
|
||||
|
||||
promise::new_promise(function(resolve, reject) {
|
||||
promises::promise(function(resolve, reject) {
|
||||
task <- function() {
|
||||
if (rx$is_alive()) {
|
||||
later::later(task, 0.1)
|
||||
|
||||
@@ -68,7 +68,7 @@ plotPNG <- function(func, filename=tempfile(fileext='.png'),
|
||||
createGraphicsDevicePromiseDomain <- function(which = dev.cur()) {
|
||||
force(which)
|
||||
|
||||
promise::new_promise_domain(
|
||||
promises::new_promise_domain(
|
||||
wrapOnFulfilled = function(onFulfilled) {
|
||||
force(onFulfilled)
|
||||
function(...) {
|
||||
|
||||
@@ -19,7 +19,7 @@ Context <- R6Class(
|
||||
run = function(func) {
|
||||
"Run the provided function under this context."
|
||||
|
||||
promise::with_promise_domain(reactivePromiseDomain(), {
|
||||
promises::with_promise_domain(reactivePromiseDomain(), {
|
||||
withReactiveDomain(.domain, {
|
||||
env <- .getReactiveEnvironment()
|
||||
.graphEnterContext(id)
|
||||
@@ -181,7 +181,7 @@ wrapForContext <- function(func, ctx) {
|
||||
}
|
||||
|
||||
reactivePromiseDomain <- function() {
|
||||
promise::new_promise_domain(
|
||||
promises::new_promise_domain(
|
||||
wrapOnFulfilled = function(onFulfilled) {
|
||||
force(onFulfilled)
|
||||
ctx <- getCurrentContext()
|
||||
|
||||
@@ -98,7 +98,7 @@ renderPlot <- function(expr, width='auto', height='auto', res=72, ...,
|
||||
dims <- if (execOnResize) getDims() else isolate(getDims())
|
||||
pixelratio <- session$clientData$pixelratio %OR% 1
|
||||
p1 <- drawPlot(name, session, func, dims$width, dims$height, pixelratio, res)
|
||||
p1 <- promise::catch(p1, function(reason) {
|
||||
p1 <- promises::catch(p1, function(reason) {
|
||||
# Non-isolating read. A common reason for errors in plotting is because
|
||||
# the dimensions are too small. By taking a dependency on width/height,
|
||||
# we can try again if the plot output element changes size.
|
||||
@@ -116,7 +116,7 @@ renderPlot <- function(expr, width='auto', height='auto', res=72, ...,
|
||||
session <<- shinysession
|
||||
|
||||
p1 <- drawReactive()
|
||||
p1 <- promise::then(p1, function(result) {
|
||||
p1 <- promises::then(p1, function(result) {
|
||||
dims <- getDims()
|
||||
pixelratio <- session$clientData$pixelratio %OR% 1
|
||||
resizeSavedPlot(name, shinysession, result, dims$width, dims$height, pixelratio, res)
|
||||
@@ -175,9 +175,9 @@ drawPlot <- function(name, session, func, width, height, pixelratio, res, ...) {
|
||||
domain <- createGraphicsDevicePromiseDomain(device)
|
||||
grDevices::dev.control(displaylist = "enable")
|
||||
|
||||
p1 <- promise::with_promise_domain(domain, {
|
||||
p2 <- promise::resolved(func())
|
||||
p2 <- promise::then(p2, function(value, .visible) {
|
||||
p1 <- promises::with_promise_domain(domain, {
|
||||
p2 <- promises::promise(~resolve(func()))
|
||||
p2 <- promises::then(p2, function(value, .visible) {
|
||||
if (.visible) {
|
||||
# A modified version of print.ggplot which returns the built ggplot object
|
||||
# as well as the gtable grob. This overrides the ggplot::print.ggplot
|
||||
@@ -205,7 +205,7 @@ drawPlot <- function(name, session, func, width, height, pixelratio, res, ...) {
|
||||
NULL
|
||||
}
|
||||
})
|
||||
p2 <- promise::then(p2, function(value) {
|
||||
p2 <- promises::then(p2, function(value) {
|
||||
list(
|
||||
plotResult = value,
|
||||
recordedPlot = grDevices::recordPlot(),
|
||||
@@ -216,10 +216,10 @@ drawPlot <- function(name, session, func, width, height, pixelratio, res, ...) {
|
||||
})
|
||||
p2
|
||||
})
|
||||
p1 <- promise::finally(p1, function() {
|
||||
p1 <- promises::finally(p1, function() {
|
||||
grDevices::dev.off(device)
|
||||
})
|
||||
p1 <- promise::then(p1, function(result) {
|
||||
p1 <- promises::then(p1, function(result) {
|
||||
result$img <- dropNulls(list(
|
||||
src = session$fileUrl(name, outfile, contentType='image/png'),
|
||||
width = width,
|
||||
@@ -230,7 +230,7 @@ drawPlot <- function(name, session, func, width, height, pixelratio, res, ...) {
|
||||
))
|
||||
result
|
||||
})
|
||||
p1 <- promise::finally(p1, function() {
|
||||
p1 <- promises::finally(p1, function() {
|
||||
unlink(outfile)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1132,9 +1132,9 @@ ShinySession <- R6Class(
|
||||
|
||||
# This shinyCallingHandlers should maybe be at a higher level,
|
||||
# to include the $then/$catch calls below?
|
||||
p <- promise::resolved(shinyCallingHandlers(func()))
|
||||
p <- promises::promise(~resolve(shinyCallingHandlers(func())))
|
||||
|
||||
p <- promise::catch(p,
|
||||
p <- promises::catch(p,
|
||||
function(cond) {
|
||||
if (inherits(cond, "shiny.custom.error")) {
|
||||
if (isTRUE(getOption("show.error.messages"))) printError(cond)
|
||||
@@ -1159,7 +1159,7 @@ ShinySession <- R6Class(
|
||||
}
|
||||
)
|
||||
|
||||
p <- promise::then(p, function(value) {
|
||||
p <- promises::then(p, function(value) {
|
||||
private$sendMessage(recalculating = list(
|
||||
name = name, status = 'recalculated'
|
||||
))
|
||||
|
||||
@@ -82,8 +82,8 @@ createRenderFunction <- function(
|
||||
|
||||
renderFunc <- function(shinysession, name, ...) {
|
||||
res <- func()
|
||||
if (promise::is.promise(res)) {
|
||||
return(promise::then(res, function(value) {
|
||||
if (promises::is.promise(res)) {
|
||||
return(promises::then(res, function(value) {
|
||||
transform(value, shinysession, name, ...)
|
||||
}))
|
||||
} else {
|
||||
@@ -332,12 +332,12 @@ renderPrint <- function(expr, env = parent.frame(), quoted = FALSE,
|
||||
|
||||
renderFunc <- function(shinysession, name, ...) {
|
||||
domain <- createRenderPrintPromiseDomain(width)
|
||||
p1 <- promise::with_promise_domain(domain, {
|
||||
p2 <- promise::resolved(TRUE)
|
||||
p2 <- promise::then(p2, function(value) {
|
||||
p1 <- promises::with_promise_domain(domain, {
|
||||
p2 <- promises::promise(~resolve(TRUE))
|
||||
p2 <- promises::then(p2, function(value) {
|
||||
func()
|
||||
})
|
||||
p2 <- promise::then(p2, function(value, .visible) {
|
||||
p2 <- promises::then(p2, function(value, .visible) {
|
||||
if (.visible) {
|
||||
cat(file = domain$conn, paste(capture.output(value, append = TRUE), collapse = "\n"))
|
||||
}
|
||||
@@ -345,12 +345,12 @@ renderPrint <- function(expr, env = parent.frame(), quoted = FALSE,
|
||||
res
|
||||
})
|
||||
# TODO jcheng 2017-04-11: Is this correct, or just leftover debugging?
|
||||
p2 <- promise::catch(p2,
|
||||
p2 <- promises::catch(p2,
|
||||
function(err) { cat(file=stderr(), "ERROR", err$message) }
|
||||
)
|
||||
p2
|
||||
})
|
||||
p1 <- promise::finally(p1, ~close(domain$conn))
|
||||
p1 <- promises::finally(p1, ~close(domain$conn))
|
||||
p1
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ renderPrint <- function(expr, env = parent.frame(), quoted = FALSE,
|
||||
createRenderPrintPromiseDomain <- function(width) {
|
||||
f <- file()
|
||||
|
||||
promise::new_promise_domain(
|
||||
promises::new_promise_domain(
|
||||
wrapOnFulfilled = function(onFulfilled) {
|
||||
force(onFulfilled)
|
||||
function(...) {
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
- [ ] Non-async render functions should have their code all execute on the current tick. Otherwise order of execution will be surprising if they have side effects and explicit priorities.
|
||||
- [x] Respect execOnResize
|
||||
- [ ] Accidentally did then(cars) instead of then(~cars), which caused an *unhandled* promise exception
|
||||
- [ ] promise::resolved(logic()) should use the current reactive domain to wrap the call to logic()
|
||||
- [ ] promises::resolved(logic()) should use the current reactive domain to wrap the call to logic()
|
||||
- [ ] invisible() doesn't seem to be working correctly with renderPrint
|
||||
|
||||
@@ -36,4 +36,3 @@ An annotated render function, ready to be assigned to an
|
||||
\description{
|
||||
Implement render functions
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user