Open JohnCoene opened 3 months ago
We have written a note about this in the documentation that it would be easier to inherit from plot_block
(https://blockr-org.github.io/blockr/articles/plot-block.html#to-do-list):
On the Shiny side, we have to handle the plot output element. Remember that the server_output() generic is defined in the {blockr} server.R script. It supports tables with server_output.block() and plots with server_output.plot_block(). Therefore, we don’t need to create another S3 method and have to make sure our new plot block inherits from the plot_block class to dispatch to the correct method.
That does not solve the rendering issue for {ggiraph}
for which you'd have to add extra methods for the output:
uiOutputBlock.ggiraph_block <- function(x, ns) {
ggiraph::girafeOutput(ns("plot"))
}
server_output.ggiraph_block <- function(x, result, output) {
ggiraph::renderGirafe(result())
}
Sorry if I was not clear.
Creating the methods for uiOutputBlock
and server_output
is precisely what I want to do, what I'm saying here is that I don't think there is a need to re-implement generate_server
. Moreover it's currently not possible today to create such blocks without knowing we have to use the unexported generate_server_block
function.
We should have a method for block
on generate_server
so that we don't need to implement this or export generate_server_block
.
We have to create a lot of custom blocks with custom renderers, e.g.: for plotly, ggiraph, etc. (an example below).
When we create a new custom block that does not inherit from
plot_block
,transform_block
, ordata_block
we have to reimplement thegenerate_server
method because there is no method forblock
.I've never had to change that method, it would be a lot of work anyways, the function
generate_server_block()
should work fine for most (probrably all) blocks.