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

Default reactive domain not accessible in downloadHandler callback #669

Closed
wch opened this issue Dec 10, 2014 · 1 comment
Closed

Default reactive domain not accessible in downloadHandler callback #669

wch opened this issue Dec 10, 2014 · 1 comment

Comments

@wch
Copy link
Collaborator

wch commented Dec 10, 2014

The function getDefaultReactiveDomain() should return a session object, which is an environment. This is what happens in regular reactives and observers, but in a downloadHandler callback, it simply returns NULL.

Example:

shinyApp(
  ui = bootstrapPage(
    downloadLink('download'),
    textOutput('txt')
  ),
  server = function(input, output) {
    output$download <- downloadHandler(
      'foo.txt',
      function(file) {
        # domain is NULL
        domain <- getDefaultReactiveDomain()
        print(domain)

        writeLines(format(domain), con = file)
      }
    )

    # Works here
    output$txt <- renderPrint({
      getDefaultReactiveDomain()
    })
  }
)
@wch
Copy link
Collaborator Author

wch commented Dec 12, 2014

A workaround for now is to pass session to withProgress and incProgress:

shinyApp(
  ui = bootstrapPage(
    downloadLink('download')
  ),
  server = function(input, output, session) {
    output$download <- downloadHandler(
      'foo.txt',
      function(file) {
        withProgress({
          incProgress(session = session)

          writeLines("test test", con = file)

          incProgress(session=session)
        }, session = session)
      }
    )
  }
)

@wch wch closed this as completed in d9336d0 Dec 12, 2014
wch added a commit that referenced this issue Dec 12, 2014
Make default reactive domain available in request handlers. Fixes #669
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

No branches or pull requests

1 participant