feat: return a list of Content class objects from search_content()#463
feat: return a list of Content class objects from search_content()#463toph-allen merged 2 commits intomainfrom
Content class objects from search_content()#463Conversation
| #' my_content <- search_content(client, q = "owner:@me") | ||
| #' | ||
| #' shiny_content <- purrr::keep(my_content, function(x) { | ||
| #' x$content$app_mode == "rmd-shiny" | ||
| #' }) |
There was a problem hiding this comment.
This is a bit of an odd example, no? I suspect it's there to show that (currently) one should use purrr::keep(...) for filtering, but in this case, you would actually want to do my_content <- search_content(client, q = "owner:@me type:rmd-shiny") to do this.
There's an arc of work to make the list more-easily-filterable that we should take up (later/next), but IMO we should document the stuff we're building now with how it should be used today, even if there might be other ways to do / other tasks folks might do with stuff like this in the future.
There was a problem hiding this comment.
Good point!! Perhaps I should use the longer example I used in GitHub PRs that uses a comparison that isn't possible in the filter API at the moment.
[edit] And/or just remove this example.
Intent
Instead of returning a list of lists from
search_content(), return a list ofContentclass objects. This allows users to use existing content-related functions with the list viapurrr.Fixes #452
Fixes #448
Approach
This is pretty minimal so far — just changing the class of the returned object.
Using
purrrto act upon the list of content is not an ideal workflow, but this is the first step towards something more user-friendly. See the original issue.Documentation is not ideal. The
Connectclass does not document available fields, and the fields documented onget_content()are out of date. I filed #461 to track this.Checklist
NEWS.md(referencing the connected issue if necessary)? [Not needed]devtools::document()?