Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactivity: resources #31

Open
7 tasks
NullVoxPopuli opened this issue Jan 27, 2024 · 1 comment
Open
7 tasks

Reactivity: resources #31

NullVoxPopuli opened this issue Jan 27, 2024 · 1 comment

Comments

@NullVoxPopuli
Copy link

NullVoxPopuli commented Jan 27, 2024

Blocks:

the idea of resources is that they're the "destroyable" primitive, a more ergonomic way to do setOwner + associateDestroyableChild + registerDestructor (from @ember/destroyable) -- and would be an implementation detail for many higher-level things


open questions

  • property access vs "being a value"
    • NVP: Why not both? there is no ergonomic difference between accessing properties on this vs accessing properties on anything else, imo. Accessing properties on this and making them "look like" the reactive thing (like @tracked) requires the usage of a decorator to hide the inner getter/setter.
  • should we base everything off ECMA resources?
    • supporting these is a good idea
      • NVP: but there is a current lack of convention around them (so I don't think they should be "the" resource implementation -- our resources could build on top of them though), (and Symbol.dispose isn't available yet). To use these, we'd have to require that folks define getters on their return object, like:
        function Greet(name) {
          return {
            get someValue() {
              return `hi, ${name}`;
            }
            [Symbol.dispose]() { /* ... */ }
          }
        }
        
        <template>
          {{Greet "NVP"}} -- can't work with ECMA resources, renders the object
        
          we'd have to do this:
          {{#let (Greet "NVP") as |x|}}
            {{x.someValue}}
          {{/let}}
        </template>
    • do we want a consistent property-access only story around reactivity in general? (something @chancancode brought up, against using arrow functions for deferring reactivity instead of getters)
      NVP: I think we need to document how reactivity works in general (we haven't yet! 🙈 ), and maybe this is a power-user technique, idk. Personally, I'm yet to be convinced on the importance of unifying on one-off classes / getters / properties instead of arrows. (this is slightly tangential to resources, but the patterns created by resource ergonomics so far have made us realize we have a lot of unanswered questions around reactivity in general)

See also:

@kategengler
Copy link
Member

Possibly descoped from Polaris after discussion at 2024 f2f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

2 participants