Copy link to clipboard
Copied
Hello,
I can't understand something after working on a project for a long time, and it's gotten to the point I am going to ask for outside help
I have an item renderer bound to an array collection.
I thought that the way bindings worked, was that properties bound to an item changed when it's value changed. But that seems to be wrong, at least for array collections.
Say my item renderer is bound to multiple properties of the data object. Here's an edited snippet of the IR code -
<s:Label id="starttime" text="{startTime}" ..
<s:Label id="endtime" text="{endTime}" ...
startTime and endTime are local properties I update via the set data function.
Now, in my model code, I say something like this...(more edited code):
var inst:instrument = getInstrumentByEndpointUrl( endpoint_url) as instrument;
if ( inst != null)
{
inst.capture_start = startTime;
inst.capture_end = endTime;
After that first line, the item render's set data is invoked. Clearly there's unknown code in the array collection which forces the binding logic to fire, calling set data for each live item renderer.
As I set multiple properties, this behavior is unpleasant, as I don't know when set data will be called. I finish the model code by calling .refresh() on the array collection. Is that the best practice to make sure the item renderers will reflect the model's state even though the framework could be calling them multiple times?
I also had to be very careful with code, as I have to assume the item renderer's set data function can be called in the middle of an update to the objects store in the array collection. I feel I am just hoping this all works in the end as I can't find a coherent explanation online of how this behavior works.
Can anyone help with some explanation of best practices when dealing with item renderers, array collections, and objects in the array collection with multiple properties that the IR is dependent on? I am totally willing to add more details if needed.
Thanks for any help anyone can provide. I have spend hours via google trying to get answers on this, and given up but this code has to be 100% correct and I am not sure I am doing it right.
Have something to add?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now