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

Bug: arg session not passed down from on() to watch() #17

Open
ilyaZar opened this issue Jul 4, 2023 · 0 comments · May be fixed by #18
Open

Bug: arg session not passed down from on() to watch() #17

ilyaZar opened this issue Jul 4, 2023 · 0 comments · May be fixed by #18

Comments

@ilyaZar
Copy link
Contributor

ilyaZar commented Jul 4, 2023

When working with the tests/testthat/test-funs.R file I realized that the following code part does not work:

library(shiny)
library(gargoyle)

shiny::reactiveConsole(TRUE)
s <- shiny::MockShinySession$new()

init("pif", session = s)
#> [[1]]
#> reactiveVal: [1] "0"
test_for_on_function <- on(
  "pif",
  {
    cat("TEST fails")
  },
  session = s
)
test_for_on_function$.func()
#> Error in session$userData[[name]](): attempt to apply non-function
shiny::reactiveConsole(FALSE)

A more specific error message is goes on:

error message

Warning: Error in session$userData[[name]]: attempt to apply non-function 51: gargoyle::watch [/home/iz/Dropbox/r-pkgs/gargoyle/R/funs.R#107] 50: eval_tidy 49: eventFunc 36: observeEvent(gargoyle::watch("pif")) 35: contextFunc 34: env$runWith 27: ctx$run 26: run 7: flushCallback 6: FUN 5: lapply 4: ctx$executeFlushCallbacks 3: .getReactiveEnvironment()$flush 2: flushReact 1: cb

This is probably because inside the on() function:

on <- function(
  name,
  expr,
  session = getDefaultReactiveDomain()
  ){
  ...
  observeEvent(
      substitute(gargoyle::watch(name)),
  ...
}

the gargoyle::watch(name) does not update the session i.e. it should probably be gargoyle::watch(name, session = session).

May be fixed by #18

ilyaZar added a commit to ilyaZar/gargoyle that referenced this issue Jul 6, 2023
- adding the session argument in view of ColinFay#17 and ColinFay#18
- remove redundant whitespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant