How to return all inputs from a module as a list of reactives?

I was wondering, how to generate a list of all inputs in a module automatically (without specifying the id's) and return that list? For instance in the official tutorials the way we return inputs is this: Shiny - Communication between modules

      xvar = reactive({ input$xvar }),
      yvar = reactive({ input$yvar })

Replacing the list with lapply results in an error:

lapply(input, function(x){reactive({input[[x]]})})

as.list.reactivevalues() is deprecated as of shiny 0.4.0.
Please use reactiveValuesToList() instead.
Please see ?reactiveValuesToList for more information.
Warning: Error in .getReactiveEnvironment()$currentContext: Operation not allowed without an active reactive context.
• You tried to do something that can only be done from inside a reactive consumer.

I tried with reactiveValuesToList but it did not help. This answer returns something different, a reactive with a list of all values.

A simple return(input) seems to be a workaround. But it breaks the reactive result style, since the input is a list of reactiveValues and not reactives.


lapply(input, function(x) reactive(x))

Shorter: lapply(input, reactive).

1 Like

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.