Remix this project for yourself
https://x.thunkable.com/copy/51110cfe7be3d03586abf8bc4cdaec07
Overview
The goal for this project is to create a to-do list app that does two things:
- Users can click a switch to indicate they have completed a task
- When a task is marked completed, this should be reflected on all users devices
Store switch states in the cloud
Create a variable to store all the switch positions (or states) and when the app starts initialise this as an empty list
Note that this should only be used while testing, as it clears the list every time the app starts!
Set all the switch states
Using a loop, go through the switches one at a time. Read the switch state from the switchStates
cloud variable and set the switch accordingly.
Create a local list of switch states
This is by no means the most reliable method, but of apps that aren’t being used by 100s of users at the same time then it shouldn’t be too bad.
Anytime a switch is changed, we loop through all the switches and store each state into a new variable called localSwitchStates
. Once this is completed then the entire local list is saved to the cloud.
Label1 is used in this app for debugging.
Add more Switches
The final part, for this tutorial, is trying it out with multiple switches. Once a switch is created it’s important to give it a starting value (I’ve gone with “false” but “true” is fine too) and then update app the switches to show the new switch on all users devices.