From 400f64031da1954d0767f00a9cef3b76d9a7d259 Mon Sep 17 00:00:00 2001 From: Nicolas Bennett <3158446+nbenn@users.noreply.github.com> Date: Wed, 23 Oct 2024 10:46:31 +0200 Subject: [PATCH] allow evaluate null --- R/block-core.R | 9 +++++++-- R/server.R | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/R/block-core.R b/R/block-core.R index 452b6366..b739837f 100644 --- a/R/block-core.R +++ b/R/block-core.R @@ -220,13 +220,18 @@ generate_code.call <- function(x) { #' @inherit new_block #' @param ... For generic consistency. #' @export -evaluate_block <- function(x, ...) { +evaluate_block <- function(x, data, ...) { + + if (!missing(data) && is.null(data)) { + return(NULL) + } + UseMethod("evaluate_block") } #' @rdname evaluate_block #' @export -evaluate_block.data_block <- function(x, ...) { +evaluate_block.data_block <- function(x, data, ...) { stopifnot(...length() == 0L) diff --git a/R/server.R b/R/server.R index 4ffc81b8..0bf5bc6c 100644 --- a/R/server.R +++ b/R/server.R @@ -212,7 +212,7 @@ generate_server_block <- function( { if (!is_valid$block) { NULL - } else if (is.null(in_dat()) && !inherits(x, "transform_block")) { + } else if (inherits(x, "dataset_block")) { evaluate_block(blk()) } else { evaluate_block(blk(), data = in_dat()) @@ -226,7 +226,7 @@ generate_server_block <- function( reactive({ if (!is_valid$block) { NULL - } else if (is.null(in_dat()) && !inherits(x, "transform_block")) { + } else if (inherits(x, "dataset_block")) { evaluate_block(blk()) } else { evaluate_block(blk(), data = in_dat())