JuliaGizmos / Escher.jl

Composable Web UIs in Julia
https://juliagizmos.github.io/Escher.jl
Other
335 stars 63 forks source link

How to work with signal of arrays? #200

Closed YayeIrene closed 7 years ago

YayeIrene commented 7 years ago

Hello, I am having trouble working with working with signal of arrays. I have written a code that takes inputs from the UI using the following commands:

n = Signal(4)
...
hbox(subscribe(clambda, slider(0.0:360.0, value = 1.5))) # there are a bunch of them

I then use the command map to run a julia function:

output = map(baffle_force, n, ab, ae)

the function return an array so typeof(output) is: Reactive.Signal{Array{Float64,1}}

If I print output I can see the different values (on the same row). But I am not able to access the elements of the array. How can I access those values?

Thank you!

YayeIrene commented 7 years ago

Hello, I got an answer on stackoverflow: map(x->x[2], S)

where S is the Signal object. This will give you the second element in a way that will update automatically when S changes.

shashi commented 7 years ago

Glad you got the answer. Sorry for not responding earlier.