Open fmmattioni opened 4 years ago
The preface is really good! I love how comprehensive it is, and as a shiny (beginner) developer, it makes me want to read the book even more. This is quite exciting β mainly because I was waiting for this kind of material for a while.
I really appreciate that you mention different packages throughout the book. For example, I did not know about highcharter
before. I will definitely give it a try in one of my shiny apps.
I guess it would be worth adding like an info block here briefly explaining what node.js is. I mean, when you get your first contact with JavaScript it is somewhat confusing to understand that there are different JavaScript frameworks β which does not exist in R (I guess?).
This was another great overview. I appreciate the details about JSON even though it is assumed that the reader already has a basic knowledge of it. I did not know about the auto_unbox
argument, for example.
Also, perhaps this is out of the scope of this chapter, but when working with nested tibbles, for example, additional steps are required. This is covered in this blogpost. Perhaps it gets things a bit complicated for the reader, but I thought it would be worth mentioning it.
The overview regarding the difference between var
, let
, and const
was very good. I personally still did not know that. This was explained in a very concise and clear way. Thank you for this chapter!
Thank you Felipe!
Something is missing here π
This is another great overview. Chapter 2.2 was crucial for understanding this part now. I need to confess that perhaps I wouldnβt know exactly what βserializationβ means in this context β which is nicely covered in chapter 2.2. This diagram that you produced with the background process is really good to understand what is going on.
This chapter was the most exciting for me so far! It feels like magic! Thanks for that, John! The nicest thing about this chapter and also chapter 4 is that you make the reader to realize that html widgets are simply a piece of html code (like a short web page) to render the desired output. This is something I did not realize before.
Overall, the chapter 5 was really great. The examples are really simple and let us discover the different possibilities in a very organized way. It already gives me some ideas for new html widgets!
Oh, with the introduction of Chapter 6 I now realize that every time we want to build a new html widget and this relies in a JS library, we should always check the dependency documentation to see how the HTML is built? That makes sense! If that is true, I guess it would be nice to have an info box to highlight this (perhaps in chapter 4).
There is nonetheless one remaining issue: peity.js is meant to create inline charts within
<span>
HTML tags but these are created within<div>
hence each chart appears on a new line.
That is weird⦠for me it appeared in the same line.
I guess it is also good to remind the reader that they need to devtools::load_all()
before running this example. Someone might get overwhelmed by the amount of new information β which also contains some JS code.
Perhaps a quick note here saying that restarting the R session is also always a good idea would be useful too. If the reader comes from the code of Chapter 6.1, they will have a vector called peity
in their environment. Then, when they do devtools::load_all()
they will get the following:
Loading peity
Warning message:
ββ Conflicts βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ peity conflicts ββ
x peity() masks peity::peity()
Did you accidentally source a file rather than using `load_all()`?
Run `rm(list = c("peity"))` to remove the conflicts.
UPDATE: I guess I got confused by the above... a vector does not create this conflict.. I might have sourced the file manually indeed. Oops! My bad!
Wow! My first impression when I was reading it without the running the code was: βOK, there is no way this is going to work. I guess John forgot something here.β. And then when I run it: voilΓ‘! For it was confusing because peity_html()
is not called anywhere in the code. I did not know that htmlwidgets
does that. That is interesting! At this point I feel like: βI guess I better read the htmlwidgets
documentation to understand this better.β. Perhaps you could point the reader to their documentation here?
This is only a small detail, but when you say:
Reloading the package after placing the function above anywhere in the package will produce inline charts.
It actually is right below the myWidget_html()
example, and not peity_html()
.
This book is blowing my mind every chapter! This is truly incredible!
Do you think it is worth it to add a info block with a quick explanation of what is a callback function
?
The example code should be dir.create("inst/htmlwidgets/stats")
instead of dir.create("htmlwidgets/stats")
. And then download.file(url, destfile = "inst/htmlwidgets/stats/stats.min.js")
instead of download.file(url, destfile = " htmlwidgets/stats/stats.min.js")
.
That is weird.. This stats example did not work for me. I get a blank page and the following in the console:
The analogy in the last paragraph about the Imports
and Suggests
was great!
This was a more complex chapter for me. I guess it is because I never worked with crosstalk
before. The explanation is great, though. I guess if I would have to implement it in a package with another JS library it would require me some extra time to think about it. I should definitely read more about crosstalk
.
In this first example you reminded me that I can rename a column directly in dplyr::select()
. Thanks for that! π
Every time I run these examples I get so excited! Do you have a list at the end of the book with cool JS libraries to try it out? That would be cool! Perhaps some sort of challenge that the reader could put all of this in practice.
I got really curious by the following:
We might want to wrap all or some of these in a single function to provide a more convenient API to the R user.
I guess I know what you mean, but not exactly. Do you think it is worth it to provide a very simple example with gio.js
?
Thanks @fmmattioni, plenty of useful comments in there!
I'm about to get to writing the book; I'll come back to these in the coming month.
Sounds good, John! I will be updating my comments here as I go... Thank you for the opportunity once again for reading this book. Truly love it!
Hey John, I just came across something interesting...
I was following the book for building an HTML widget, which worked quite well, by the way... The interesting thing, however, is that when running in shiny
I was getting the following error:
Warning: Error in addResourcePath: addResourcePath called with invalid prefix; please see documentation
Then, I took a look again at chapter 6.1
and noticed that the field name
did not have any spaces in your example. Then, I thought to be worth the try to give names without spaces, and it worked! Do you think it could be worth mentioning this detail in this chapter?
To illustrate what I had:
dependencies:
- name: Highcharts annotations
version: 8.2.2
src: htmlwidgets/highcharts
script: annotations.js
The funny thing is that this worked normally when calling the widget. However, in shiny
I always got that error. Changing Highcharts annotations
to annotations
made the trick.
Dear John, first of all, thank you so much for this book! I am having a lot of fun reading it! This is the resource I have been waiting for!
I am going to put here my comments once I finish every section of the book. Some comments are more general, some are more specific. Feel free to ignore any of them β they are just thoughts I had while reading the book.