Observing `ContainerView` as an array


#1

Is there a practical alternative to observing ContainerView as an array? I need to manually manage an array of views, and some of those views have properties based off of their position within their parent, for example:

number: function getNumber() {
  return `Number ${this.get('parentView').indexOf(this)}: `;
}.property('parentView.[]')

I’m getting deprecation warnings, but am not aware of an alternative.


#2

I guess the new fangled way would be to switch your views to components and pass in the parental index data.

Using the awesomeness of each with index you could do something like

{{#each people as |person index|}}
  {{! The first index value will be 0 }}
  {{your-awesome-component position=index}}
{{/each}}

#3

Ah, good call. I’ll give this a whirl.