Creating "credits" in Shiny that continually reduce based on a click event?

experimentaldesign

#1

I'm helping to program an R Shiny app that is designed to introduce "scarcity" in access to certain types of information. Users can only access certain types of information if they have a sufficient number of "tokens" or "credits". Each user is endowed with an initial number of credits, and they have to budget those credits so they can access the information most important to them.

The challenge is, I'd like these credits to reduce as users make decisions on the app. I've had some luck using observeEvent, but the credits do not keep reducing in this case. I know this must be possible, but am I going about it the wrong way with observeEvent?

Any pointers would be much appreciated!

Regards,