-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
Hello everyone,
When building a package that is exporting a generic function, what is the proper way to export a method for a class within a "Suggests" package?
For example, if package foo exports the foo() generic, but lists package bar as a Suggests, what would be the proper way to register methods for classes within bar?
Would it be something to the effect of:
# from the foo package
.onLoad <- function(lib, pkg) {
if (isNamespaceLoaded("bar")) {
method(foo, bar::class_bar) <- function(x) {cat("we dispatched on `bar::class_bar`")}
} else {
setHook(packageEvent("bar", "onLoad"), function(){
method(foo, bar::class_bar) <- function(x) {cat("we dispatched on `bar::class_bar`")}
})
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels