Skip to content

Commit

Permalink
Merge pull request #476 from Appsilon/use-latest-box
Browse files Browse the repository at this point in the history
Use the latest box
  • Loading branch information
kamilzyla authored Jul 6, 2023
2 parents 0095925 + a3f37aa commit fe3fbef
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rhino
Title: A Framework for Enterprise Shiny Applications
Version: 1.3.1.9001
Version: 1.3.1.9002
Authors@R:
c(
person("Kamil", "Żyła", role = c("aut", "cre"), email = "[email protected]"),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
2. Add E2E tests for the Rhino package (internal).
3. Add support for using React in Rhino
(tutorial, JS function `registerReactComponents()`, R function `react_component()`).
4. Require box v1.3.1 or later (fixes issues with lazy-loaded data and trailing commas).

# [rhino 1.3.1](https://github.com/Appsilon/rhino/releases/tag/v1.3.1)

Expand Down
8 changes: 1 addition & 7 deletions R/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ setup_box_path <- function() {
}
}

# Make it possible to reload the app without restarting the R session.
purge_box_cache <- function() {
loaded_mods <- loadNamespace("box")$loaded_mods
rm(list = ls(loaded_mods), envir = loaded_mods)
}

configure_logger <- function() {
config <- config::get()
log_level <- config$rhino_log_level
Expand Down Expand Up @@ -126,7 +120,7 @@ with_head_tags <- function(ui) {
#' @export
app <- function() {
setup_box_path()
purge_box_cache()
box::purge_cache()
configure_logger()
shiny::addResourcePath("static", fs::path_wd("app", "static"))

Expand Down
2 changes: 1 addition & 1 deletion R/tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' }
#' @export
test_r <- function() {
purge_box_cache()
box::purge_cache()
testthat::test_dir(fs::path("tests", "testthat"))
}

Expand Down
27 changes: 14 additions & 13 deletions vignettes/explanation/box-modules.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ Introduction of box to existing apps written without it
has helped to improve the code structure and find bugs.

# Usage
The best place to learn about box is its official [documentation](https://klmr.me/box/).
The best place to learn about box is its official [documentation](https://klmr.me/box/).
The discussion here will mainly focus on how to use box inside Rhino.

Rhino suggests the use of [`app/logic` and `app/view`](https://appsilon.github.io/rhino/articles/explanation/application-structure.html).
Rhino creates these directories by default.
Code that is independent of Shiny should be kept in `app/logic`
Rhino creates these directories by default.
Code that is independent of Shiny should be kept in `app/logic`
while code using or related to Shiny modules should be kept in `app/view`.
This structure makes it easy to make a nested hierarchy of code with the help of box.

Expand Down Expand Up @@ -106,7 +106,7 @@ server <- function(id) {

```

With explicit attaching of function names, it is clear from above that the code
With explicit attaching of function names, it is clear from above that the code
uses `shiny.semantic::textInput()` and not `shiny::textInput()`.

```r
Expand Down Expand Up @@ -189,19 +189,20 @@ box::use(

# Known issues

The following issues were fixed in box v1.1.3, which is required by Rhino starting with v1.4.0.
This section is left here for reference.

### Lazy-loaded data
The following issue is fixed in box v1.1.3. Rhino v1.4.0 requires box v1.1.3 or later
Box 1.1.0 doesn't support lazy-loaded [data](https://r-pkgs.org/data.html#data-data),
so e.g. `box::use(datasets[mtcars])` won't work.
This feature should be available in the next release

Prior to v1.1.3 box didn't support lazy-loaded [data](https://r-pkgs.org/data.html#data-data),
so e.g. `box::use(datasets[mtcars])` wouldn't work
(see this [issue](https://github.com/klmr/box/issues/219)).
For now please use `datasets::mtcars` in your code.
It was possible to workaround it by using `datasets::mtcars` instead.

### Trailing commas
Box 1.1.0 allows trailing commas in `box::use()` statements and code,
but they can cause problems in some circumstances:

Box allows trailing commas in `box::use()` statements and code,
but prior to v1.1.3 they could cause problems in some circumstances:

1. Reexports ([issue](https://github.com/klmr/box/issues/263)).
2. Functions accessed via `$` ([issue](https://github.com/klmr/box/issues/266)).

Both issues should be fixed in the nearest release.

0 comments on commit fe3fbef

Please sign in to comment.