Best Practice for using formulas vs. variables

According to the docs, weweb distinguishes between local and global formulas. I suppose, technically there are also component formulas, formulas scoped to a component.

Does weweb handle formulas as computed properties, that is, is the result value cached and only recalculated when referenced variables change? If not, this might have implications for where to use formulas, or rather variables that get assigned by a workflow using a formula.

So what would be the best practice here?

  • When should you avoid using formulas?
  • Is it okay to use them in data bindings of CSS atributes?
  • Is it okay for formulas to have side effects or to modify the DOM?
1 Like

Formulas are the equivalent of computed in Vue. All same rules should apply

1 Like

as a general rule don’t use a formula when it’s not a pure function without side effects or when it’s an async function. in those cases you need workflows and variables

1 Like