Rhino 1.7.0 Update on CRAN: Improved Linting and Automatic Reloading

[This article was first published on Tag: r - Appsilon | Enterprise R Shiny Dashboards, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

It’s been almost a month since the last release of our framework for enterprise Shiny applications, so it’s time for Rhino 1.7! This version comes with new rules for the R linter, more consistent loading behavior, and automatic app reloading during development. Read on for the details!

Curious about building enterprise-grade Shiny apps with Rhino? Discover how with our detailed tutorial.

Table of Contents


Improved Linting with Rhino 1.7

Rhino puts a strong emphasis on code quality. It supports your efforts in this area by providing you with a thoughtful project structure and powerful development tools like linters, which can ensure a consistent style of your code and detect potential problems.

Rhino 1.7 introduces several new rules for rhino::lint_r(). These rules are designed to support the best practices for using {box}, our tool of choice for structuring your project:

  • Explicitness: Don’t import all names with module[...] syntax. This pattern makes it difficult to understand how modules are used and can lead to name clashes (example).
  • Import sections: Use separate import statements for packages and modules. This makes it easier to understand the dependencies and structure of your project.
  • Import limit: Don’t import more than 8 names from a single module – use the module$name syntax instead. This makes it easier to read and maintain the import statements.
  • Trailing commas: Use trailing commas in the import statements. This simplifies adding and reordering lines.

You can read more about these rules in our Rhino Style Guide.

Interested in learning more about Rhino? Sign up for Shiny Gatherings #11 with Kamil Żyła on the 27th February at 6pm CET to explore the latest developments in Rhino. 

Refactored rhino::app()

Rhino promotes a unified approach to structuring your application using {box} and Shiny modules. Even the top-level UI and server are defined this way. This uniform structure improves readability and simplifies refactoring.

Vanilla Shiny gives you more leeway in this area. For example, you can define your UI in any of the following ways:

ui <- titlePanel("Hello!")
ui <- function() titlePanel("Hello!")
ui <- function(request) titlePanel("Hello!")

This flexibility comes in handy sometimes. For example, you might want to process the request parameter, or use a package designed to wrap the entire UI and server of your application. Rhino offers an escape hatch for such use cases – the legacy entrypoint – but historically, it had some issues.

In Rhino 1.7 we have undertaken a major refactor of rhino::app(). This is mostly an internal improvement, which will provide a solid foundation for future development, but there are benefits for end users too:

  1. The app loading and reloading behavior is now more consistent.
  2. When using a legacy entrypoint, any UI or server definition accepted by vanilla Shiny should work with Rhino as well.

Automatic Reloading with Rhino

You can build interactive web applications extremely fast with Shiny, thanks to its powerful reactivity system and a wide variety of available components. Rhino helps you to maintain this high speed of development in the long term by supporting you in applying the best software engineering practices.

Rhino 1.7 takes another step to speed up development and to make it more convenient. The refactor described in the previous section has paved the way for supporting automatic app reloading. To enable it, simply set the shiny.autoreload option for the R session where you’re running your application:

options(shiny.autoreload = TRUE)

Your application will now be reloaded automatically whenever any changes are detected in the source files!

Please remember that this setting should only be used in development. You can read more about automatic reloading in shiny-options.

How to Install the Latest Version of Rhino

Try out the new features today! You can grab the latest version from CRAN by running:

install.packages("rhino")

To migrate your existing Rhino project, check out the Rhino 1.7 Migration Guide.

Rhinoverse

Rhino can be a solid foundation for your Shiny application, but it doesn’t end there. Rhino is the centerpiece of a larger ecosystem – Rhinoverse, a family of open-source R packages created by Appsilon to address the needs of modern web development.

Make sure to check out the other members of the family on rhinoverse.dev!


Conclusion

With improved linting rules, a streamlined app structure, and the introduction of automatic reloading, developers now have even more tools at their disposal to ensure code quality, enhance productivity, and maintain the agility required for rapid iteration.

Upgrade to Rhino 1.7 today, and join us at Shiny Gatherings #11 to explore new developments in Rhino.

Interested in taking your R/Shiny skills to the next level? Download our free ebook today to explore advanced topics such as best practices for software development and integrating user analytics into your Shiny apps. 

 

The post appeared first on appsilon.com/blog/.

To leave a comment for the author, please follow the link and comment on their blog: Tag: r - Appsilon | Enterprise R Shiny Dashboards.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)