Skip to contents

Takes a condition written in javascript notation (visibility conditions in ui_structure.json) and evaluates it in R.

Usage

evaluate_condition(js_condition, session)

Arguments

js_condition

The javascript condition to evaluate as a string

session

Current Shiny session in which to evaluate

Value

Returns either TRUE or FALSE. If the condition could not be evaluated, returns NULL.

Note

Might not be best coding practice, but works as long as the js_condition doesn't have any typos. eval(parse(...)) is dangerous if it is used directly with user input, but here that is not the case. The user has no access to the ui_structure.json file.

Running this function in a reactive context will create reactive dependencies. This is actually useful, because then we know exactly when e.g. relevant variables need to be recalculated.