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

Set Bookmark Include #96

Open
JT-39 opened this issue Nov 21, 2024 · 0 comments
Open

Set Bookmark Include #96

JT-39 opened this issue Nov 21, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@JT-39
Copy link
Collaborator

JT-39 commented Nov 21, 2024

Is your feature request related to a problem? Please describe.
The default is for all inputs to be included in the bookmarking, except those specified in the default server.R's setBookmarkExclude(c(...)).

This becomes quite unwieldly as app become larger. In my case I forgot about the bookmarking and it worsened the performance of my app (due to mismatching inputs being remembered and causing an infinite error refresh loop). Also, it is effort to remember to update this list each time you add a new input.

Describe the solution you'd like

Introducing... setBookmarkInclude().

Clue in the name it basically does the opposite of setBookmarkExclude(). It does so my getting the list of all current inputs, then uses setdiff() to remove the inputs you want to add to the bookmark from the list of all inputs. Finally it passes this list of all other inputs to setBookmarkExclude().

I think this makes maintenance of the bookmarked inputs much easier and more explicit.

This could quite easily be turned into a function - setBookmarkInclude() (I think).

  shiny::observe({
    # Exclude all inputs except the specified ones dynamically
    include_inputs <- c("input_include-1", "input_include-2", "input_include-3")
    excluded_inputs <- setdiff(names(shiny::reactiveValuesToList(input)), include_inputs)

    # Set the excluded inputs for bookmarking
    shiny::setBookmarkExclude(excluded_inputs)

    # Trigger bookmarking whenever relevant inputs change
    session$doBookmark()
  })

Describe alternatives you've considered

Haven't really...

Additional context

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants