-
Notifications
You must be signed in to change notification settings - Fork 22
fix: Expose id in ui/server methods to support Shiny for R modules and multiple instances
#172
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
Conversation
1744be8 to
c9206b7
Compare
gadenbuie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked considering the idea of passing in ns() (it's a creative solution!), but it feels little off compared to the established patterns we use with Shiny modules.
In #173 I'm proposing that we expose id directly, while still allowing for the server-side rendered case to "just work". More than just solving the Shiny modules use case, that opens up re-using a qc object for more than chat instance.
…173) * refactor: Allow directly providing `id` * chore: Also `$sidebar()` and update docstrings
|
@gadenbuie mind updating the description and taking this over the finish line? |
|
@cpsievert I updated the PR description, made the |
id in ui/server methods to support Shiny for R modules and multiple instances
|
Thanks! LGTM other than the one suggestion. |
Co-authored-by: Carson Sievert <[email protected]>
Closes #169
This PR introduces proper support for using QueryChat within Shiny (for R) modules by allowing explicit
idparameter overrides in$ui(),$sidebar(), and$server()methods.Key Changes
1. Added
idparameter to$ui(),$sidebar(), and$server()methods:idwhen calling these methodsid = ns("your_id")2. Follows idiomatic Shiny module patterns:
ns()in the UI function3. Enables multiple instances from the same QueryChat object:
idoverride, users can create multiple chat interfaces from a single QueryChat instanceImplementation Details
$ui()and$sidebar()to accept an optionalidparameter instead ofnsfunction$server()to accept an optionalidparameteridis not provided, falls back toself$idwith automatic namespace detection (vianamespaced_id()) for UI methodsiddirectlyUsage
In a Shiny module UI function:
In a Shiny module server function:
In a regular Shiny app (no module):