Skip to content

Commit

Permalink
memoise onload, closes #60
Browse files Browse the repository at this point in the history
  • Loading branch information
jsta committed Jan 16, 2020
1 parent 697f944 commit 1b96c85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/load.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ nhd_load <- function(state, dsn, file_ext = NA, approve_all_dl = FALSE, ...){
#' # Character VPU
#' plusflow <- nhd_plus_load(vpu = "10L", "NHDPlusAttributes", "PlusFlow")
#' }
nhd_plus_load <- memoise::memoise(function(vpu, component = "NHDSnapshot", dsn,
nhd_plus_load <- function(vpu, component = "NHDSnapshot", dsn,
file_ext = NA, approve_all_dl = FALSE, force_dl = FALSE,
pretty = FALSE, ...){

Expand Down Expand Up @@ -265,4 +265,4 @@ nhd_plus_load <- memoise::memoise(function(vpu, component = "NHDSnapshot", dsn,
}

res
}, cache = memoise::cache_memory())
}
5 changes: 5 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@
packageStartupMessage("The 7-zip program is needed to unpack NHD downloads (http://www.7-zip.org/).")
}
}

.onLoad <- function(libname, pkgname) {
nhd_plus_load <<- memoise::memoise(nhd_plus_load,
cache = memoise::cache_memory())
}
# nocov end

0 comments on commit 1b96c85

Please sign in to comment.