While building the application with {golem}
, the package with the app is not installed on your machine.
When you use {future}
, the code is run inside another R session, meaning that the objects are transported and the libraries reloaded.
BUT if you try to use a function from inside your current app into your future, you need to make it "transportable", and using package_name::function()
will not work because your package is not installed.
Let's say you need to use current_app_fun()
, defined inside your package.
Technically, {future}
will be able to transport this function, as it uses {globals}
to identify the objects to transport to the new R session.
observeEvent( input$bla , {
# future() will identify that it needs to
# transport current_app_fun()
future({
current_app_fun()
})
})
You can also do an extra step just to be extra cautious:
observeEvent( input$bla , {
func_for_future <- current_app_fun
future({
func_for_future()
})
})
Cheers,
Colin