This page is part of a static HTML representation of TriTarget.org at https://tritarget.org

Simple box pattern for data down actions up in Ember

Sukima 4th December 2020 at 7:31pm

Read Managing change in Ember article for more information.

<MyComponent
  @value={{@thing.property}}
  @update={{@thing.update.property}}
/>

If @thing were a class (like Octane likes) then the above pattern is nothing more then a one-liner:

class Thing {
  @tracked property;
  update = new Proxy(this, {
    get: (t, p) => Reflect.has(t, p) ? v => t[p] = v : undefined
  });
}
[Anonymous]: didn't you just describe a poorer implementation of a box?
[Me]: yes, yes I did 😉