Open espors opened 2 years ago
In addition to testing if figure is an object, we could take steps to ensuring the object has the correct state, and detecting any dependencies it before the image is downloaded . For example, I found a bug where a ggplot object call p is not reactive, but if I pass p into the module with parentheses, like this: p <- ggplot(...) + geom_histogram()
dl_hist_r <- mod_download_figure_server(
"dl_hist_r",
filename = "histogram_r",
figure = reactive({ p() })
)
the module appears to work perfectly downloading a pdf with the correct name and extension. But the pdf is actually corrupted and will not open. This was resolved by removing the parentheses by p.
dl_hist_r <- mod_download_figure_server(
"dl_hist_r",
filename = "histogram_r",
figure = reactive({ p })
)
It was my mistake using p() instead of p, but looking at the code for the demo example, _figure_ appears to be a reactive object inside another reactive call, even though the package also works by using a non-reactive object in the reactive call. The error comes from treating a non-reactive as something reactive, p() instead of p, which is something we could test for.
What
Add testing functionality