Create variable in component scope

Hello,

It would be more than interesting to be able to create variable at a component scope. And of course instance to inherit those variables.

Why ?

  • it would be a good way to organize variables. One file can have a lot of different components and subcomponents = a lot of variables.
  • it would give us the possibility to ease prototype creation by preparing upfront variables in components library.
  • it is a good way to get rid of variants. I mean variants are nice but variables are far better :).
  • it would give the possibility to create different set of variables corresponding to different state of the components faster.
1 Like

Is this the type of solution you are looking for?

Your proposal is a good addition, but we need scope on file, section, and instance level.

Section prevents everything breaking when you move things between files, but it doesn’t address the component-level issue. Let’s say you make a counter component like this:

( - 0 + )

Each instance needs its own copy of the component’s counter number variable or it breaks. If I make a screen with four separate counters on it, I need to manually make four number variables and wire them all separately. It’s extremely messy and inefficient.

The ideal solution is to expose component properties to the logic system. The only needed change is to allow one boolean property to be used in multiple places in a component with positive and negative checks (show if logged in vs. show if not logged in).

As a side-effect, this would make variable organization much simpler.

4 Likes

Yeah I could use this, like today.

I want to have several instances of a component, each with their own separate variable instance values so I can manage logic and state for each instance independently of each other.