Skip to content

Replace trim_rv() and the internal reactives class with the reactives package #361

Description

@nbenn

Two workarounds in blockr.core are now covered by the reactives package, which grew out of #227 and #244:

  • trim_rv() removes keys from a reactiveValues() object through shiny's internals. destroy_link() uses it on the per-block routing in rv$sources[[id]] (created here), and it is exported because blockr.dock uses it too.
  • The internal reactives class holds the variadic ...args (created here).

With the package:

  • The routing in rv$sources[[id]] becomes a reactives::reactive_vals() collection. Removing a variadic link is src[[id]] <- NULL, and reading a key returns its reactiveVal() or NULL, which upstream_result() calls when present. The reactiveValuesToList(srcs) calls in block_inputs_ready() and block_server() (L354, L447) read the values of all slots instead, which Add helpers for bulk reads, type checks and tests nbenn/reactives#7 plans a helper for.
  • The variadic ...args becomes a reactives::reactives() collection. Since as.list() returns the slots' reactives, dot_arg_values() calls each one, while block servers keep using names() and length(). The copies of dot_arg_values() in blockr.io and blockr.dm already call elements that are reactives.
  • The environment of per-block reactiveVal()s in rv$needed_slots, and rv$eval, where removing a block leaves a NULL key behind, can move to collections as well.
  • The trim_rv() export can be deprecated once blockr.dock no longer uses it.

Tests in blockr.dm, blockr.dplyr, blockr.ggplot and blockr.io build ...args with blockr.core:::reactives() and blockr.core:::append_reactive(), often with plain functions such as function() df1. They would switch to reactives::reactives(), with each slot wrapped in reactive(), since the package only accepts reactives.

This needs a CRAN release of reactives first, since blockr.core is on CRAN. It should also follow nbenn/reactives#4, which creates each key's cell in the session that owns the collection, because blockr.core destroys a block's module session when the block is removed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions