Passing Values vs. References in Dropzone Variables - Update variable wrapped in object

I am exposing variables via the dropozone data to dropzone elements and want to change them (assign a new value to them).

It turns out, I can not assign to these variables directly from within the children. There seems to be some local change, but it does not persist and trigger updates on bindings (so maybe change detection does not work here) → Video.

It does not matter whether the variable in the dropzone data object is a literal, a component or global variable. It seems the change must be triggered by the parent for it to be picked up.

Changing a global variable directly, not via the dropzone object, the change takes effect from within the child:

Is there an explanation for this behavior? Can I still make it work from within the dropzone child elements or does it have to be via the parent providing the dropzone?


Description: Changing dropzone variable does not work via javascript assignment in child element but works by triggering parent workflow doing the assignment via javascript or change variable value action.

In this Topic it is said that exposed component variables are read only. Apparently this is true, but I dont’t understand why.

I try to assign the global variable via javaScript:

It seems to update in the Log. But again, no update of the bound text field:

It turns out it’s probably a question whether you pass a reference or a value. So in order to get a reference you need to wrap variables into an object and pass that object. This will preserve the reference and you can change dropzone values from within the dropzone element/child.

Booleans, strings, number and interstingly enough, arrays are apparently passed by value and thus you can’t change the referenced value. All you change is the local value.

Define a component variables of type object containing custom variables and expose it through the dropzone, so the dropzone elements/children can update the values directly by reference:

It seems to work with both component and global objects, but also with literal objects.

Exposed object variables still can’t be updated though, apparently.



This topic can be considered solved, but maybe someone would like to add to it.

Component props are readonly, rigth? It seems changing them does not trigger change detection.

And I am actually still confused, why it would not work with arrays.
Here, it looks like it does make a difference whether I pass an array directly as property or via a dropzone variable. → Video

Another observation: Literal objects update, only if you also update a variable object and expose it via the dropzone data object. I suppose, it’s just a side effect that the literal is updated too, when the variable gets updated, recalculating the whole dropzone data object.

I see it as a not very great practice to use global variables in your components. Always try to use props. Passing objects lets you update them, but other variables shouldn’t work.

I’d also like to avoid global variables. That’s why I am trying to get reactivity by using dropzone data.

In my experience, properties seem to be read only, even when passing objects. I need to use component variables initialized with the property value and then work with the variable. How do you make it work with props directly, if I understood you correctly?

Do you have experience with arrays? In my understanding arrays should be objects and therefore be passed by reference.

Reference: