In Section 7.6 (Environments - As data structures), the bullet about "Managing state within a package" seems especially useful, and leaves me wanting more details about this approach.
While a reference to those examples (or others) may be useful to readers, by showcasing use cases, this issue was created because I am interested to learn more about this approach in general:
What are the limitations of using this approach to manage package states?
Would this work in a package intended to be used in a Shiny App, or other uses that may load libraries in a new R session?
What are some prevailing best practices around this approach?
I am uncertain where the best place to answer these questions is (other options: R Packages, Posit Community), but thought I'd mention it here since there is a dedicated bullet in the book.
In Section 7.6 (Environments - As data structures), the bullet about "Managing state within a package" seems especially useful, and leaves me wanting more details about this approach.
I have found a few examples of this in the wild:
here package (R/here.R#L37)
usethis package (R/proj.R#L1)
The blog post "Closing Database Connections in R Packages"
While a reference to those examples (or others) may be useful to readers, by showcasing use cases, this issue was created because I am interested to learn more about this approach in general:
What are the limitations of using this approach to manage package states?
Would this work in a package intended to be used in a Shiny App, or other uses that may load libraries in a new R session?
What are some prevailing best practices around this approach?
I am uncertain where the best place to answer these questions is (other options: R Packages, Posit Community), but thought I'd mention it here since there is a dedicated bullet in the book.