I'm interested in getting rid of "Data binding will not be able to
detect changes when using square bracket operator" without introducing
an ArrayCollection.
The view displays data for the seven days of the week. Not using a
repeater (though one could).

I invite opinions on the relative merits (performance/elegance) of the
following:

A) Split the data in the presentation model when the combined data comes in

<c:DailyView day="Monday" data="{model.mondayData}"
<c:DailyView day="Tuesday" data="{model.tuesdayData}"

Obviously only an option because there are only seven days.

B) Use a function in the view

private function dailyData(combinedDailyData:Array, dayIndex:int) {
        return model.combinedData[day]; // could also use a dictionary
}

<c:DailyView day="Monday" data="{this.dailyData(model.stuff, 0)}"/>

C) A bindable non-getter in the presentation model

<c:DailyView day="Monday" data="{model.dataForDay(0)}"/>

In the model:
[Bindable(event="combinedDataChanged")]
public function dataForDay(day:int):Array {
  return combinedData[day];
}

Obviously the setter for combinedData dispatches "combinedDataChanged".

I actually wasn't aware, or had forgotten, that C) is possible on a
non-getter function until I tried it just now. I actually like this
option because it encapsulates the storage used (array, dictionary,
whatever). I think I just answered my own question.

Reply via email to