Closed TylerGrantSmith closed 2 years ago
Yeah, makes sense. Are you interested in doing a PR?
Hi @TylerGrantSmith,
I just wanted to say thank you for the code you posted above - it helped me out a lot for a slightly different use case.
In my instance, I'm allowing users to trigger an scheduled markdown (that normally runs hourly) using connectapi, and I wanted to show the time a pin was created to the user to reflect the trigger, however there is no pin_meta()
equivalent for pin_reactive_read()
, meaning my metadata was out of sync with the data itself.
I've adapted your functions for my use case:
pin_created <- function(board, name) {
pin_meta(board, name)$created
}
custom_pin_reactive_meta <- function(board, name, interval) {
rlang::check_installed("shiny")
shiny::reactivePoll(intervalMillis = interval,
session = shiny::getDefaultReactiveDomain(),
checkFunc = function() {
pin_created(board = board, name = name)
},
valueFunc = function() {
pin_meta(board = board, name = name)
})
}
I just thought I'd share this in case it is useful for anyone else.
Some further thoughts are that some flexibility between using pin_hash()
and pin_created()
should be possible, because a hash only changes if the pins' content changes, but not if it is re-written without changes.
Thanks again!
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.
the
pin_reactive_read
function sets up ashiny::reactivePoll
object usingpin_created
as thecheckFunc
. However, this is not ideal, becausepin_created
only seems to return a timestamp with accuracy to the minute, and so if a pin is updated twice within the same minute, the reactive is never triggered. Wouldn't it make more sense to use the hash value? Here is an example shiny app.