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

Don't run effects created in a MockSession #1049

Merged
merged 1 commit into from
Jan 23, 2024
Merged

Don't run effects created in a MockSession #1049

merged 1 commit into from
Jan 23, 2024

Conversation

wch
Copy link
Collaborator

@wch wch commented Jan 23, 2024

Closes #1034.

This PR makes it so that when a @reactive.effect is used in the UI-rendering phase of a Shiny Express app, it's a no-op; it doesn't schedule the function to be run later, during a reactive flush.

Some thoughts about how this might be improved/generalized in the future:

  • MockSession and Session could to both be subclasses of another class, like BaseSession. Or MockSession could just be a subclass of Session.
  • In effect.__init__(), it currently does an explicit check if session is a MockSession object, but that is a bit crude. Instead, Session and MockSession could have a method, like is_reactive(), which effect.__init__() could query to find out whether it should schedule execution on a reactive flush.
  • The MockSession.__init__() method could take an argument, is_reactive, to tell it whether to do reactivity or not. This could be useful if the MockSession class is used for other purposes, like testing.

@wch wch requested review from jcheng5 and cpsievert January 23, 2024 05:31
@wch wch added this to the v0.7.0 milestone Jan 23, 2024
@wch wch merged commit bfd5192 into main Jan 23, 2024
26 checks passed
@wch wch deleted the express-session branch January 23, 2024 18:10
schloerke added a commit that referenced this pull request Feb 13, 2024
* main: (33 commits)
  test: Test apps locally before deploying via pytest fixtures. (#1055)
  docs: Add ExtendedTask to API index (#1088)
  Fix `render.download` in Shiny Express, take 2 (#1085)
  Bump version to 0.7.0.9000
  Create two different api doc folders, one for Core and one for Express (#1053)
  chore: Pin black to version 23 (#1077)
  chore: Remove github link to shinylive (#1069)
  Bump version to 0.7.0
  Raise when `express.[input,output,session]` are used outside of Express app (#1067)
  Update dashboard template (#1056)
  chore: Remove many broken quartodoc links (#1061)
  Update {bslib} (#1062)
  Update docstrings for `expressify`, `hold`, and `render.express` (#1066)
  Add `fill` to `__all__` in `ui` and `express.ui` (#1064)
  Update shiny.js (#1059)
  docs(examples): Use refactored shinylive syntax (#1048)
  Update `shiny.js` (#1052)
  Add `express.ui.panel_title` (#1039)
  Don't run `effect`s created in a `MockSession` (#1049)
  Delete shiny/api-examples/Calc directory (#1044)
  ...
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.

Updating express inputs leads to an error
2 participants