-
Notifications
You must be signed in to change notification settings - Fork 292
Expand file tree
/
Copy pathfaq-adverbs-export.Rd
More file actions
44 lines (38 loc) · 1.31 KB
/
faq-adverbs-export.Rd
File metadata and controls
44 lines (38 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/faq.R
\name{faq-adverbs-export}
\alias{faq-adverbs-export}
\title{Best practices for exporting adverb-wrapped functions}
\description{
Exporting functions created with purrr adverbs in your package
requires some precautions because the functions will contain internal
purrr code. This means that creating them once and for all when
the package is built may cause problems when purrr is updated, because
a function that the adverb uses might no longer exist.
Instead, either create the modified function once per session on package
load or wrap the call within another function every time you use it:
\itemize{
\item Using the \code{\link[=.onLoad]{.onLoad()}} hook:
\if{html}{\out{<div class="sourceCode">}}\preformatted{#' My function
#' @export
insist_my_function <- function(...) "dummy"
my_function <- function(...) \{
# Implementation
\}
.onLoad <- function(lib, pkg) \{
insist_my_function <<- purrr::insistently(my_function)
\}
}\if{html}{\out{</div>}}
\item Using a wrapper function:
\if{html}{\out{<div class="sourceCode">}}\preformatted{my_function <- function(...) \{
# Implementation
\}
#' My function
#' @export
insist_my_function <- function(...) \{
purrr::insistently(my_function)(...)
\}
}\if{html}{\out{</div>}}
}
}
\keyword{internal}