I’ve been testing Number Variables with a voting component which can have multiple instances on in a single frame.
Preface
Currently I have #Vote Count
Default value set to 0.
From a default state, tapping the voting component will increase the value by 1 and set the state to “active”. Tapping from the active state will decrease the value by 1 and set the state to “inactive”.
This works great if I’m using a single instance of the component with no divergence from the value I’ve set in the Local Variable collection.
In my use case, this component is nested in a card which has multiple instances. Interacting with one of the instances will update the #Vote Count
value globally.
While I know I can add multiple “mode” values to the collection and set them individually for each instance this seems like an overhead nightmare.
My Suggestions
- When using `Set Variable’, Having an option to manipulate a value locally (Per instance) or globally.
- When creating a number variable, having the option to set an actual number or a reference variable that can be set locally.
- For example, I set
#Vote Count
= x and apply that variable to a text layer, then create an instance and set that layer to 6. Using the logic outline above, tapping from default should give me a value of 7 and tapping again will give me a value of 6 for that specific instance.
This would allow for a more robust variable that side steps management overhead of a predetermined list.