Skip to content
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

Minimally invasive result field fix #439

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .lintr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ linters: linters_with_defaults(
line_length_linter = line_length_linter(100L),
object_name_linter = NULL, # Because we use S3 and end up with is_initialized.field
object_usage_linter = NULL, # When code is WIP this is annoying ...
commented_code_linter = NULL # When code is WIP this is annoying ...
commented_code_linter = NULL, # When code is WIP this is annoying ...
cyclocomp_linter(16L)
)
exclusions: list(
"inst/examples/cdisc-plot/example.R",
Expand Down
9 changes: 7 additions & 2 deletions R/block-core.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
15 changes: 10 additions & 5 deletions R/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ generate_server_block <- function(
out_dat <- if (attr(x, "submit") > -1) {
eventReactive(input$submit,
{
req(is_valid$block)
if (is.null(in_dat())) {
if (!is_valid$block) {
NULL
} else if (inherits(x, "dataset_block")) {
evaluate_block(blk())
} else {
evaluate_block(blk(), data = in_dat())
Expand All @@ -223,8 +224,9 @@ generate_server_block <- function(
)
} else {
reactive({
req(is_valid$block)
if (is.null(in_dat()) && !inherits(x, "transform_block")) {
if (!is_valid$block) {
NULL
} else if (inherits(x, "dataset_block")) {
evaluate_block(blk())
} else {
evaluate_block(blk(), data = in_dat())
Expand Down Expand Up @@ -829,7 +831,10 @@ init_block <- function(i, vals) {
#' @rdname server_output
#' @export
server_output <- function(x, result, output) {
UseMethod("server_output", x)

if (not_null(result)) {
UseMethod("server_output", x)
}
}

#' @rdname server_output
Expand Down
Loading