Skip to content

autoreload feature #234

@grst

Description

@grst

While developing interactively, it would be fantastic if the modules are re-loaded automatically in the background every time a module has changed. This is how the %autoreload magic works in jupyter notebooks.

Use-case

1. Working on rmarkdown documents

I believe it is considered good practice to only have the code directly needed for generating the report within the rmarkdown document itself and to refactor helper functions into a separate file. Now, if I work on the document and have my helper functions loaded with, say box::use(./utils), I need to run reload(utils) every time I change a utility function.

2. Modular shiny apps

I found that box is a quite effective way to structure modular shiny apps. The only downside is that when hitting the "Reload App" button in Rstudio wil not reload any changes I made to the shiny modules I loaded with box. My current workaround is to have a reload(module) right underneath each use(module).

Suggested implementation

Enable autoreload by setting a global configuration flag, e.g.

box::set_autoreload(TRUE)

# or borrowing flags from ipython's %autoreload
box::set_autoreload(2)

I don't know how this would work under-the-hood, but probably watch all files from which functions have been imported and
trigger box::reload every time a file has changed.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions