-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use req() in checkFunction ReactivePoll #3976
Comments
Hi @HugoGit39, thanks for the question! The main issue is that USER_LOGGED_IN <- reactiveVal(FALSE)
observeEvent(input$login, {
message("User has logged in.")
# Pretend that the user has now logged in
USER_LOGGED_IN(TRUE)
})
# Function to poll for updated data every 30 seconds
data_poll <- reactivePoll(
intervalMillis = 5000,
session = session,
checkFunc = function() {
if (!USER_LOGGED_IN()) {
message("Not logged in yet.")
return()
}
# Return a timestamp to trigger polling
message("Data check: ", format(Sys.time(), "%H:%M:%S"))
format(Sys.time(), "%H:%M")
},
valueFunc = function() {
# Generate new data
req(USER_LOGGED_IN())
generate_data()
}
) I've put this modification in a small shinylive app from your example. |
@gadenbuie Thx!. But the checkFunc is running already from the start. Isnt there a way to start the checkFunc (or the reactivePoll function) when the user logs in? |
No, the way that The idea in my updated example is to have |
Right, but it its still a nice feature to have |
No, the code you use for |
Hi
So I have the current workflow:
A shiny app where a user signs in via Firebase. Once signed it, I have an
observeEvent
that observes the sign in where areactivevalue
changes toTRUE
value. Once this happens I want areactivePoll
starts running to load a dataframe from a server, which needs to be refreshed based on the day. When I addreq()
tocheckFunction
it errors, however when I add it tovalueFunction
it does work, howeverreactivePoll
starts running once a user opens the app without signing-in, which I do not want.I have a simplified code with a button which is a metphore for signing in and
reactivePoll
check every 30 seconds for the minute so the data changes once the button is clickedThe text was updated successfully, but these errors were encountered: