Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing behavior on setindex! of a vector Observable #31

Closed
vilim opened this issue Dec 3, 2018 · 4 comments
Closed

Confusing behavior on setindex! of a vector Observable #31

vilim opened this issue Dec 3, 2018 · 4 comments

Comments

@vilim
Copy link

vilim commented Dec 3, 2018

I find the following behavior a bit confusing (from Makie examples):

points = Observable(Point2f0[(0, 0), (0.5, 0.5), (1.0, 0.0)]) # AbstractPlotting renames Observables to Nodes it seems

later, in a function

          points[][idx[]] = pos
          points[] = points[]

The example does not work if the last line is excluded, even though it seems to be doing nothing. Is the issue that points[][idx[]] = pos somehow does not send a change signal?

@mschauer
Copy link

My take: points[] = ... calls setindex! on an observable, triggering a signal.
points[][1] = ... calls getindex on an observable (and setindex!es the result), not triggering a signal.

@vilim
Copy link
Author

vilim commented Apr 25, 2019

Ah, that makes sense, thanks! Maybe there could be a more intuitive method of triggering the signal, somehting like trigger(points), that executes the rest of the setindex[] method, without the first line? Or just as an alias for that line? Performance-wise, I guess o.val = val is anyway compiled to a no-op.

@goretkin
Copy link

Probably more semantically obvious than points[] = points[] is to do Observables.notify!(points).

@twavv
Copy link
Member

twavv commented Mar 23, 2020

I'm going to close this as intended behavior.

It might make sense to warn more about using mutable values inside of observables in the documentation.

@twavv twavv closed this as completed Mar 23, 2020
timholy added a commit that referenced this issue Jan 2, 2021
This can be handy when trying to figure out where some `var"#31#32"`
function was defined.
timholy added a commit that referenced this issue Jan 4, 2021
This can be handy when trying to figure out where some `var"#31#32"`
function was defined.
timholy added a commit that referenced this issue Jan 4, 2021
This can be handy when trying to figure out where some `var"#31#32"`
function was defined.
timholy added a commit that referenced this issue Jan 4, 2021
This can be handy when trying to figure out where some `var"#31#32"`
function was defined.
timholy added a commit that referenced this issue Jan 4, 2021
This can be handy when trying to figure out where some `var"#31#32"`
function was defined.
timholy added a commit that referenced this issue Jan 9, 2021
This can be handy when trying to figure out where some `var"#31#32"`
function was defined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants