Uno JS TreeArray iterate

Hi fuse,

I’m writing custom expression class and now i need to iterate javascript array in uno code. How to iterate javascript array in uno ?

public sealed class Sum: BinaryOperator
	public Sum([UXParameter("Left")] Fuse.Reactive.Expression left, [UXParameter("Right")] Fuse.Reactive.Expression right): 
		base(left, right, "sum") {}
	protected override bool TryCompute(object left, object right, out object result)

		 debug_log  left;  /* this is give me class name Fuse.Scripting.JavaScript.TreeArray;  

tried  this => Fuse.Scripting.JavaScript.TreeArray ar=left as Fuse.Scripting.JavaScript.TreeArray;  and throw an error

Fuse.Scripting.JavaScript does not contain type or namespace 'TreeArray'. Could you be missing a package reference?

		return true;

Hi Hilmi,

before we suggest anything particular, could you please show us some context? i.e., how are you going to use this in UX, and why?

Thanks UIdis,

I liked expression thing, and start playing with this :slight_smile:

Particularly i’m use vue.js to web side and vue have ‘mixins’. Some of my components have dynamic behaviour. i.e. pivot tables column aggregation like this;

RN, CT_1, CT_2, CT_3, … CT_N -> CT_{?} is dynamic columns and i need only aggregate this columns per row, i solve this with mixin in vue. Or create function ‘sum’ named and it aggregate object array -> sum(objArray,‘columnName’)

I’m trying to do something like this;

var objArray=[{name:'H1',total:500},{name:'H2',total:400},{name:'H3',total:750}];

<Text Value="{=sum({objArray},'total')}" /> // 1650

always boring to write the same thing on several pages

Understood. In Fuse, you’ll be better off doing these types of calculations in JavaScript, using .map on your Observables, flattening them or if you’re using the new FuseJS/Models approach, you could just have a getter on a class.