Skip to content

Conversation

@schloerke
Copy link
Collaborator

Sets a method that can be called by the client via Shiny.shinyapp.makeRequest(). Shiny.shinyapp.makeRequest() makes a request to the server and waits for a response. By using makeRequest() (JS) and set_message_handler() (python), you can have a much richer communication interaction than just using Input values and re-rendering outputs.

For example, @render.data_frame can have many cells edited. While it is possible to set many input values, if makeRequest() did not exist, the data frame would be updated on the first cell update. This would cause the data frame
to be re-rendered, cancelling any pending cell updates. makeRequest() allows for individual cell updates to be sent to the server, processed, and handled by the existing data frame output.


Removes Session._output_binding_request_handler() and all methods used to support it.

Now, there is no coincidences and users opt-in directly to the method:

Ex:

        ...
        request_key = session.set_message_handler(
            f"data_frame_patches_{self.output_id}",
            handler_fn,
        )

The request_key is then set to the client so that it know where it can make requests. The request_key is namespaced by the session, so authors do not need to handle it themselves.

@schloerke schloerke marked this pull request as ready for review March 27, 2024 15:55
@schloerke schloerke merged commit 10b8e68 into main Mar 27, 2024
@schloerke schloerke deleted the data_frame_message_handler branch March 27, 2024 16:06
schloerke added a commit that referenced this pull request Mar 27, 2024
* main:
  feat: Create `Session.set_message_handler(name, handler)` (#1253)
  Fix input name
  Enable error console when running locally. (#1060)
  test: Update test to use variable, not capture stdout (#1236)
schloerke added a commit that referenced this pull request Mar 28, 2024
* main:
  test(CI): Add merge queue support for faster PR testing (#1265)
  fix(panel_conditional): Include `.shiny-panel-conditional` class (#1257)
  feat: Create `Session.set_message_handler(name, handler)` (#1253)
  Fix input name
  Enable error console when running locally. (#1060)
  test: Update test to use variable, not capture stdout (#1236)
  test: Fix deploys for shinyapps.io and connect (#1224)
  chore(test): Playwright test refactors and clean up (#1204)
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 this pull request may close these issues.

3 participants