NullVoxPopuli / ember-resources

An implementation of Resources. Supports ember 3.28+
https://github.com/NullVoxPopuli/ember-resources/blob/main/docs/docs/README.md
MIT License
91 stars 37 forks source link

Quest: Sync with starbeam developments: (and actually get the lint implemented, since we have some footguns to protect against) #1012

Open NullVoxPopuli opened 11 months ago

NullVoxPopuli commented 11 months ago

Tasks

Notes:

resource(({ on }) => {
  evaluateCount++;
  on.sync(() => () => cleanupCount++);

  // THIS IS ILLEGAL. You can't read reactive values in the constructor
  // (because the entire would be torn down each time @input @changes)
  return this.args.input;
});

should instead be

resource(({ on }) => {
  on.sync(() => {
    syncCount++;
    return () => cleanupCount++;
  });

  return Formula(() => this.args.input);
});

however, Formula doesn't exist in ember-resources, and may not make sense today, as ember-resources already supports returning () => some value, and it's already a "cached value" (via the createCache api (which is internal in the helper managers)

NullVoxPopuli commented 9 months ago

Note: on.sync us impossfto implement in ember, pre-starbeam.

But moving the resource body into on.sync in the codemod should be safe/consistent