-
Notifications
You must be signed in to change notification settings - Fork 206
Update widget_html #377
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
Update widget_html #377
Conversation
Should I add myself as a contributor? |
Sorry I missed this earlier, @thebioengineer. I misread your original suggestion in #376, what I thought you were proposing was:
This way, there's no breakage in backwards compatibility, and it's using the actual S3 generic dispatch mechanism instead of our own lookalike. The harder question is when and how we would deprecate the old way, I think a PR like the above would be the first step which would allow us to update our docs. The next step would be to search CRAN reverse imports/dependencies and @timelyportfolio's repos to see if anyone is actually using the old way. Sorry for the miscommunication! And let me know what you think of this proposed approach. |
Gotcha! Yeah, we can do that. I'll work on that tonight. |
@jcheng5 @thebioengineer I agree this should be |
…o provide type checking and setup for use of html_widget.
hey @jcheng5, I update html_widgets to behave like an s3 method. To facilitate the actual s3 method dispatch, I created a wrapper function - Not sure I like this solution over our pseudo s3 dispatch method because I now we will have to export the methods, and so will the widget authors. I added .Deprecated() to warn users about the changing methodology, but we can remove that if we want to hold off. I checked this with both {reactable} and {leaflet} and it appeared to work still. |
Other than my nit picky comment, this looks great now, thanks! I don't see exporting the generic (or |
… implementing s3 method, it is conceivable to return other housings.
|
||
widget_html <- function(name, package, id, style, class, inline = FALSE, ...){ | ||
fn_res <- widget_html( | ||
name = structure(name, class = c("character", name)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I just noticed this little detail, give me a second to get my head around this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK s3 methods are deployed based on the class of the object into UseMethod. This sets that. Otherwise we need to do our own s3 deployment method. unless there is another way to decide which s3 method to use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with setting the classname on the name is that it's a lie; we shouldn't tag objects with class names unless they actually are objects of that class. I didn't look closely enough at this initially and just assumed an x
object was being passed in and that would be what we use for S3 dispatch. I had forgotten that this widget_html
can be called before any x
object exists--namely, in shinyWidgetOutput
, where we're just generating the markup which won't actually be populated with the widget until the server renders it.
So that being the case, I don't think it makes sense to use actual S3 dispatch, I'm fine with the pseudo-S3 approach.
Sorry for the unnecessary extra work. The first commit was pretty close, I'll cherry-pick from this PR and probably file a new one to hopefully be merged next week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, It was a good thought exercise as I went through this. I wasn't super clear about my intention for a "pseudo" s3 method implementation, just that I thought something similar might be more "R-like" and less likely to introduce someone stumbling across the widgetname_html method and getting weird results. Thanks for the review Joe!
…on only if it's defined as a formal argument
@jcheng5 - assuming this PR can be closed since your branch has been merged into master? |
Addresses #376
Suggested two updates to widget_html that are implemented here:
shiny.tag
. Throws a warning describing what it saw and what it expected.We could add a soft-deprication for the current method (name_html) if you want. I wasn't sure how we might want to do that.