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

Dev mode aware client and duplicate input/output ID handling updates #3956

Merged
merged 10 commits into from
Jan 24, 2024

Conversation

nstrayer
Copy link
Contributor

This is a follow-up to #3946 and a fix for #3950.

The main contribution is the passing of dev mode status to the client. This is done by injecting a script tag into the head of the app when in dev mode. This script tag adds a global variable to the window that is then used as a signal to the client that dev mode is activated. To avoid awkward global-variable-consuming we provide a helper method on the Shiny object: Shiny.inDevMode() that abstracts this away.

This method for relaying dev mode status is inspired by how React does it.

The ability for the client to know about dev mode status is utilized to more explicitly label the passthrough case of duplicated input and output IDs in the code...

// If there's a single duplication of ids across both binding types, then
// when we're not in devmode, we allow this to pass because a good amount of
// existing applications use this pattern even though its invalid. Eventually
// this behavior should be removed.
if (counts.input === 1 && counts.output === 1 && !Shiny.inDevMode()) {
  return;
}

// If we have duplicated IDs, then add them to the set of duplicated IDs
// to be reported to the user.
if (counts.input > 0 || counts.output > 0) {
  duplicateIds.set(id, counts);
}

... while also flagging this as an error when in dev mode.

@nstrayer nstrayer requested review from wch and jcheng5 December 11, 2023 17:45
@nstrayer nstrayer changed the title Devmode aware client Dev mode aware client and duplicate input/output ID handling updates Dec 11, 2023
@wch wch merged commit f26b133 into main Jan 24, 2024
1 check passed
@wch wch deleted the devmode-aware-client branch January 24, 2024 18:37
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.

2 participants