Setting inputs from the server

2,431 views
Skip to first unread message

Winston Chang

unread,
Apr 10, 2013, 1:50:18 PM4/10/13
to shiny-...@googlegroups.com
Hi everyone -

We've added some new features on an experimental branch:
* Setting the values of input objects from the server
* Sending arbitrary Javascript from the server to run on the client

It's not yet merged into the master development branch, but if you are feeling brave and want to experiment with it, you can install it with:
  devtools::install_github('shiny', 'wch', 'set-input')

Please note that the API is still subject to change, and it's possible that this branch could break at any time. If you do play with it and have feedback about it works, we'd like to hear it!


Here's a demo of setting inputs:
Code:


And a demo of sending Javascript:
Code:


-Winston

Alberto Santini

unread,
Apr 11, 2013, 6:20:05 AM4/11/13
to shiny-...@googlegroups.com
Hello Winston


On Wednesday, April 10, 2013 7:50:18 PM UTC+2, Winston Chang wrote:
* Setting the values of input objects from the server

This is an interesting and useful feature to develop, for instance, "converters" as the example below.
http://albertosantini.github.io/examples/mvc/temperatureExample3.html

Thanks,
Alberto

Winston Chang

unread,
Apr 11, 2013, 1:58:57 PM4/11/13
to shiny-...@googlegroups.com
Yes, it should make this kind of functionality easier and more elegant to implement. It was already possible to "set" an input by sending a dynamic UI object (which replaces the original), but the new method is much cleaner. Instead of replacing the UI, it just tells the UI object to change values.




--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dieter Menne

unread,
Apr 15, 2013, 12:27:39 PM4/15/13
to shiny-...@googlegroups.com
This is great news, Winston, it make editable field usable at last, and enabling/disabling of button easier.

There is one minor problem in the example posted on gist (forgot how I get access to glimmer, but feel free to do so). It's described in the application window.


A revised and much better
version of

https://gist.github.com/dmenne/4721235

is available now on

https://gist.github.com/dmenne/5389291

Requires developer version 0.5 of Shiny


devtools::install_github('shiny', 'wch', 'set-input')

To run

runGist("https://gist.github.com/dmenne/5389291")

Mike C

unread,
Apr 15, 2013, 1:30:46 PM4/15/13
to shiny-...@googlegroups.com
This is fantastic.  I really like the direction this is going in, my only regret is that I am almost finished my app the old fashioned way! :)

One quick question, can isolate and action buttons be applied to the session observations? ie:

observe({
if(input$goButtonx<1)
return() #make it NULL initially
input$goButtonx
x <- isolate(input$controller)#only update x each time the goButtonx is pressed

 updateTextInput(session, "inText", value = paste("New text", x)) #only updates when goButtonx is pressed
})

Mike C

unread,
Apr 16, 2013, 9:45:49 AM4/16/13
to shiny-...@googlegroups.com
Sorry for following up with another question before the first was answered, but I noticed that the setup still seemed 'hard coded' in terms of how many options were available for each field (in this example, usually 2 options in drop down menus and radial buttons).  Is it dynamicUI still the tool to use to get a variable number of inputs in a given field?

Winston Chang

unread,
Apr 16, 2013, 11:33:16 AM4/16/13
to shiny-...@googlegroups.com
You should be able to add as many options as you want. In the demo, I just put two options for each group because it was simpler to code.

-Winston


--

Winston Chang

unread,
Apr 16, 2013, 11:35:29 AM4/16/13
to shiny-...@googlegroups.com
This should work - the updaters work just like any other functions.


--

Winston Chang

unread,
Apr 16, 2013, 11:45:18 AM4/16/13
to shiny-...@googlegroups.com
Very nice. We're also looking at adding the capability for sending arbitrary JSON messages to the client; and then on the client, making it easy to add callbacks that will receive the JSON message.

In your app, instead of sending an entire Javascript command, you could send a message which would be passed to a function on the client, which would enable/disable the appropriate item.

-Winston


Paul Rigor

unread,
Jun 28, 2013, 2:22:14 PM6/28/13
to shiny-...@googlegroups.com
Just wanted to follow up on whether the changes discussed in this thread have made it to the main branch?

Thanks!
Paul

Yuan Yuan

unread,
Jun 28, 2013, 2:55:16 PM6/28/13
to shiny-...@googlegroups.com
This is very cool! Thanks, Winston and the team.

Winston Chang

unread,
Jun 28, 2013, 3:09:39 PM6/28/13
to shiny-...@googlegroups.com
Hi Paul - yes, the changes are in Shiny 0.6.0. Here's a demo:
-Winston

Reply all
Reply to author
Forward
0 new messages