-
-
Notifications
You must be signed in to change notification settings - Fork 31
Implement support for clientside callbacks in Dash for R #130
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
Merged
Merged
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b34f3f7
:sparkles: clientside functional
79b0016
:rotating_light: add test for clientside
509af82
:hammer: fix asset resolution in test
b85c6b7
:hocho: remove old test version
e4fffaf
:hammer: use app$callback for clientside
16ddb98
:books: update documentation
af6b56c
Update config.yml
rpkyle 0c65b78
:bug: debugging ...
rpkyle 1c45fe9
attempt to resolve test error
c3eae14
uncomment checks
b228846
:bulb: try to set branch from env var
73ef721
write var to file, read file
a1edd09
add informative message and force=TRUE
607f519
try abspath
28ca2e7
:see_no_evil: just use dirname
c54ea0e
once more with feeling
312b125
fix path resolution to assets
cb8fc1b
use hash
19e0785
Update R/utils.R
rpkyle 4d1768b
:hocho: whitespace
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
if(!window.dash_clientside) {window.dash_clientside = {};} | ||
window.dash_clientside.clientside = { | ||
display: function (value) { | ||
return 'Client says "' + value + '"'; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
from selenium.webdriver.support.select import Select | ||
import time, os | ||
alexcjohnson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
app = """ | ||
library(dash) | ||
library(dashCoreComponents) | ||
library(dashHtmlComponents) | ||
|
||
app <- Dash$new() | ||
|
||
app$layout(htmlDiv(list( | ||
dccInput(id='input'), | ||
htmlDiv(id='output-clientside'), | ||
htmlDiv(id='output-serverside') | ||
) | ||
) | ||
) | ||
|
||
app$callback( | ||
output(id = "output-serverside", property = "children"), | ||
params = list( | ||
input(id = "input", property = "value") | ||
), | ||
function(value) { | ||
sprintf("Server says %s", value) | ||
} | ||
) | ||
|
||
app$callback( | ||
output('output-clientside', 'children'), | ||
params=list(input('input', 'value')), | ||
clientsideFunction( | ||
namespace = 'clientside', | ||
function_name = 'display' | ||
) | ||
) | ||
|
||
app$run_server() | ||
""" | ||
|
||
|
||
def test_rscc001_clientside(dashr): | ||
os.chdir(os.path.dirname(__file__)) | ||
dashr.start_server(app) | ||
dashr.wait_for_text_to_equal( | ||
'#output-clientside', | ||
'Client says "undefined"' | ||
) | ||
dashr.wait_for_text_to_equal( | ||
"#output-serverside", | ||
"Server says NULL" | ||
) | ||
input1 = dashr.find_element("#input") | ||
dashr.clear_input(input1) | ||
input1.send_keys("Clientside") | ||
dashr.wait_for_text_to_equal( | ||
'#output-clientside', | ||
'Client says "Clientside"' | ||
) | ||
dashr.wait_for_text_to_equal( | ||
"#output-serverside", | ||
"Server says Clientside" | ||
) | ||
dashr.clear_input(input1) | ||
input1.send_keys("Callbacks") | ||
dashr.wait_for_text_to_equal( | ||
'#output-clientside', | ||
'Client says "Callbacks"' | ||
) | ||
dashr.wait_for_text_to_equal( | ||
"#output-serverside", | ||
"Server says Callbacks" | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.