JohnCoene / javascript-for-r-comments

1 stars 0 forks source link

how play.js, play.r, and play.yaml connect #39

Open MayaGans opened 3 years ago

MayaGans commented 3 years ago

Hey John!

Sorry if this isn't the best place to bother you... I have a small question - I think i made this up completely but was kind of operating under the mental model that play.js and play.r “know about” each other via the play.yaml which connects the two via name..... but when you scaffold a widget the yaml is all commented out and x.message works so how DO they know about each other?!

Thanks for being so patient and helpful! Maya

JohnCoene commented 3 years ago

Hey Maya,

The output of play will bear a class play(), this matches the name of the widget in the JavaScript file here.

The class that is used as output of play() is defined by the name given to the widget here.

The "name" is then also in the .yaml but it only enables {htmlwidgets} to find and load the appropriate dependencies, it does not "link" the JS and R, this is done via the class, which is defined by the name (in R and JS).

Note that this is also referenced here in the playOutput function.

I hope this makes sense.