rfcs icon indicating copy to clipboard operation
rfcs copied to clipboard

Key functions for `each`/`each-in`

Open mmun opened this issue 7 years ago • 2 comments

Rendered

Closes https://github.com/emberjs/rfcs/issues/306

mmun avatar Mar 24 '18 21:03 mmun

I'm definitely a :+1: on this.

With ember-apollo-client, we're always just passing either POJOs wrapped in an EmberObject or NativeArrays. Out-of-the-box, the arrays do not work cleanly with Ember unless you pass key="id" or similar to avoid re-rendering the components for the entire list. That's because the POJOs themselves do not have the same guid, so Ember thinks they're different.

However, users typically already have to tell Apollo how to get a unique identifier from their objects by configuring a dataIdForObject() function. That gets used for cache normalization purposes and typically just defaults to obj => obj.id for apps with globally unique IDs. I would love to use this same function to make it easier for users to get correct behavior on re-renders. The suggestion from @mmun was to build an {{#apollo-each}} helper that gets AST transformed to reference the key function. This RFC would make that possible.

The proposal itself seems straightforward and I would love to see it built.

bgentry avatar May 23 '18 23:05 bgentry

Seem like there has been some solid interest for this. I'm going to see if we can get some better review and a proper yay or nay on it.

wagenet avatar Jul 23 '22 17:07 wagenet

I'm moving this FCP to close since it's had virtually no activity in the last few years. If someone wants to pick this up and make sure the RFC is up to date, we can re-open.

wagenet avatar Jan 27 '23 19:01 wagenet