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

Allow InputBinding.receiveMessage to be async #3930

Merged
merged 5 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: shiny
Type: Package
Title: Web Application Framework for R
Version: 1.7.5.9000
Version: 1.7.5.9001
Authors@R: c(
person("Winston", "Chang", role = c("aut", "cre"), email = "winston@posit.co", comment = c(ORCID = "0000-0002-1576-2126")),
person("Joe", "Cheng", role = "aut", email = "joe@posit.co"),
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

* Shiny's CSS styling (for things like `showNotification()`, `withProgress()`, `inputPanel()`, etc.), has been updated with `{bslib}`'s upcoming CSS-only dark mode feature in mind. (#3882, #3914)

* Default styles for `showNotification()` were tweaked slightly to improve accessibility, sizing, and padding. (#3913)
* Default styles for `showNotification()` were tweaked slightly to improve accessibility, sizing, and padding. (#3913)

* For `InputBinding`s, the `.receiveMessage()` method can now be asynchronous or synchronous (previously it could only be synchronous). (#3930)

## Bug fixes

Expand Down
2 changes: 1 addition & 1 deletion inst/www/shared/shiny-autoreload.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/www/shared/shiny-showcase.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion inst/www/shared/shiny-showcase.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/www/shared/shiny-testmode.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

262 changes: 147 additions & 115 deletions inst/www/shared/shiny.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions inst/www/shared/shiny.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/www/shared/shiny.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions inst/www/shared/shiny.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions inst/www/shared/shiny.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"homepage": "https://shiny.rstudio.com",
"repository": "github:rstudio/shiny",
"name": "@types/rstudio-shiny",
"version": "1.7.5-alpha.9000",
"version": "1.7.5-alpha.9001",
"license": "GPL-3.0-only",
"main": "",
"browser": "",
Expand Down
2 changes: 1 addition & 1 deletion srcts/src/bindings/input/inputBinding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class InputBinding {
// 'data' should be an object with elements corresponding to value, min,
// max, etc., as appropriate for the type of input object. It also should
// trigger a change event.
receiveMessage(el: HTMLElement, data: unknown): void {
receiveMessage(el: HTMLElement, data: unknown): Promise<void> | void {
throw "Not implemented";
el; // unused var
data; // unused var
Expand Down
4 changes: 2 additions & 2 deletions srcts/src/shiny/shinyapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ class ShinyApp {

addMessageHandler(
"inputMessages",
(message: Array<{ id: string; message: unknown }>) => {
async (message: Array<{ id: string; message: unknown }>) => {
// inputMessages should be an array
for (let i = 0; i < message.length; i++) {
const $obj = $(".shiny-bound-input#" + $escape(message[i].id));
Expand All @@ -734,7 +734,7 @@ class ShinyApp {
$(el).trigger(evt);
if (!evt.isDefaultPrevented()) {
try {
inputBinding.receiveMessage(el, evt.message);
await inputBinding.receiveMessage(el, evt.message);
} catch (error) {
console.error(
"[shiny] Error in inputBinding.receiveMessage()",
Expand Down
2 changes: 1 addition & 1 deletion srcts/types/src/bindings/input/inputBinding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declare class InputBinding {
getValue(el: HTMLElement): any;
subscribe(el: HTMLElement, callback: (value: boolean) => void): void;
unsubscribe(el: HTMLElement): void;
receiveMessage(el: HTMLElement, data: unknown): void;
receiveMessage(el: HTMLElement, data: unknown): Promise<void> | void;
getState(el: HTMLElement): unknown;
getRatePolicy(el: HTMLElement): {
policy: RatePolicyModes;
Expand Down