I am writing a game based on @BDub’s pinewood derby code
What I am wanting to do is control it via a webpage. I easily figured out how to trigger the round by calling a cloud function via POST. I can also get the time variables at the end of the round by using GET.
I dont know when the round ends, it could end at any point. My question is, how can I get it to push the end of the round data to the webpage instead of having to constantly poll it with GET?
I think Spark.publish() would be ideal here. You don’t really even need the data to be published, just an event that says “I’m done and you can read my variables now!”.
Well @bko, you beat me to it. I was going to link to your tutorials anyhow, so I guess that doesn’t matter much
If you’re publishing anyhow, why wouldn’t you use that data directly. Seems to be an unnecessary step to me to say:“hey, I’ve got a live update containing data, let’s actively poll for that same data.” If you’re sending that stuff over the web, you might as well just use it. This however only hold true if the data is small enough to fit within a publish. If you’re polling a lot of variables, the “notify to poll” seems reasonable.
I wrote several on publishing and getting and setting variables.
I mentioned that you wouldn’t have to publish the actual data just to avoid more code changes since you are starting from code that uses variables. Publishing the data works great!