Skip to content

Make it easier to apply existing Content functions to lists of content #465

@toph-allen

Description

@toph-allen

#463 (in flight at time of writing) modifies search_content() to return a list of Connect class objects.

Right now, the best way to call existing functions that operate on Content class objects is to use purrr::map(). This is pretty simple if there are no additional arguments passed, but if additional args were required, you'd have to use R's anonymous function syntax.

# Assume `old_content` is a list of content class objects that need to be locked.

length(old_content)
# [1] 48

# Use purrr::map to apply existing functions to the list.
old_content <- purrr::map(old_content, lock_content)

# When passing extra args
old_content <- purrr::map(old_content, \(x) lock_content(x, locked_message = "R version is too old."))

It would be nicer if you could just pass the list to the functions and have it work, like so:

old_content <- lock_content(old_content, locked_message = "R version is too old.")

This might require us modifying all the content functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions