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

registerInputHandler support, redux #28

Merged
merged 3 commits into from
May 3, 2019
Merged

Conversation

alandipert
Copy link
Collaborator

@alandipert alandipert commented May 1, 2019

This is a second attempt at adding support for shiny::registerInputHandler(). In my first attempt, I didn't understand the purpose of getType(). Now, I understand that an input's type is a namespace distinct from the name argument of Shiny.inputBindings.register() and with a different extent. Using an input's name as its type, as I did in #26, made no sense.

An input's name is used to alter the priority of an input in the event of a DOM conflict, and there is a 1-1 correspondence between an input and its name.

An input's type, on the other hand, has a different purpose. In R, shiny::registerInputHandler() is used to associate a type with an input handler that will coerce an input's value with a a matching type from a JSON representation to some alternate R representation.

So, every input has one and only one name, and also (optionally) a type, but multiple inputs may share a type.

To implement this, I added a new property to the options argument of reactR.reactShinyInput(): type. type may be a function, used as the input's getType() implementation. For expedience, type may also be false or a type name string, which is probably the most common use case.

I updated https://github.com/react-R/colorpicker-example to demonstrate usage of the functionality in this PR.

@alandipert alandipert marked this pull request as ready for review May 2, 2019 03:17
@timelyportfolio
Copy link
Collaborator

@alandipert great work, thanks! This will be very nice to have for custom situations, which I think will be more common with reactR inputs.

@timelyportfolio timelyportfolio merged commit 63fa36e into master May 3, 2019
@timelyportfolio timelyportfolio deleted the getType-round-2 branch May 3, 2019 01:55
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.

None yet

2 participants