Shopify/batman — pull request #725 by cjoudrey (2013-05-19 14:35:18+00:00)
Title: Proposal for adding data-set and data-set-* to handle binding to data that will not change

**Ignore the implementation. It's just a proof of concept.**

### Proposal

I've been thinking about this ever since our discussion at RailsConf.

We often use `data-bind` and `data-bind-*` on attributes that we know will never change. This causes unnecessary creation of many objects (bindings, attr readers, observers, etc..)

An example of this is when we render orders:

```html

```

I'm proposing we add `data-set` and `data-set-*` which act like `data-bind` but are done once at render time.

The above example would become:

```html

```

Notice how I have not changed `data-bind="orders.paymentStatus"` to `data-set` this is because a bulk action can cause this value to be changed.

I suspect we can get good performance gains on index pages with this new attribute.

### Concerns

Using `data-set` can potentially create display issues if you have something that changes the value (i.e. Bulk Actions.) I think these would be easy to catch during development.

My biggest concern is that this means the data needs to be available at render-time.

We would need a way to figure out if all XHR requests have came back (maybe use promises?) or explicitely call `render()` in the controller action when we know we have everything needed to render the page.

### Thoughts?

@hornairs @nickjs @kristianpd @ibawt @SoapyIllusions I'd love to hear your feedback about this.