ember-resources
ember-resources copied to clipboard
Quest: Sync with starbeam developments: (and actually get the lint implemented, since we have some footguns to protect against)
Tasks
-
[ ]
on.sync- [ ] manages changes in consumed reactive values
- [ ] allows cleanup behavior to occur per set of reactive changes
-
[ ]
on.cleanupbecomeson.finalize(but keepon.cleanupfor compatibility) -
[ ] Lints
- [ ] finish https://github.com/NullVoxPopuli/ember-resources/pull/709
- [ ] add
- [ ] family of lints for inlining resource definitions within the class body
- [ ] explore forbidding consumption of tracked args within the resource body (can lint against arg usage specifically
- [ ] potentially auto-fixable to
on.sync+ return cleanup function
- [ ] potentially auto-fixable to
- [ ] favor linting for the returned
() => return value, because returning lazily accessed() => this.args.inputis fine, but returningthis.args.inputis not. - [ ] prefer defining resources in module space
- [ ] explore forbidding consumption of tracked args within the resource body (can lint against arg usage specifically
- [ ] family of lints for inlining resource definitions within the class body
-
[ ] Learning materials
- [ ] the resource body is "the constructor"-
- [ ]
on.syncallows easy managing of reactive updates, no worry about the whole thing getting torn down prematurely - [ ]
on.finalize(formallyon.cleanup) is tied to the lifetime of the parent context - [ ] before and after docs
- [ ] how to be closest to starbeam
- [ ] what was awkward before that resources make better
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)
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