Closed tobiu closed 2 weeks ago
i am still not sure if i can see the benefit of having formulas in the first place, since we can do any kind of complex bindings directly on component level.
the only reason that comes to my mind might be to "cache" binding values in case they get long. but, in this case, you can just use helper fns on cmp level. like: c: data => MyUtil.parse(data.a + data.b)
.
so i think if we want to keep vm based formulas, they have to be on the same level as default bindings, plus cmps must be able to actually use them (this part seems not to be implemented). like: e: 'formula.aPlusB'
.
can you please shed some light into this?
This issue is stale because it has been open for 90 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
the code:
does assume that bound values are string based, which they are not. it does not honor fn calls or data.property combinations.
examples of bindings on component level:
One question: do you want to support formulas which use data properties from parent VMs? Asking since this is already in place for default component based bindings (which are formulas in their own way).
To understand the parsing of our bindings, follow the chain: createBindings() => https://github.com/neomjs/neo/blob/dev/src/model/Component.mjs#L227 createBindingByFormatter() => https://github.com/neomjs/neo/blob/dev/src/model/Component.mjs#L215 getFormatterVariables() => https://github.com/neomjs/neo/blob/dev/src/model/Component.mjs#L368
Especially the last one is crucial, since it extracts data properties from fn bodies (which are strings) via regexes. You want to use it for formulas as well :)