You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
favor linting for the returned () => return value, because returning lazily accessed () => this.args.input is fine, but returning this.args.input is not.
prefer defining resources in module space
Learning materials
the resource body is "the constructor"-
on.sync allows easy managing of reactive updates, no worry about the whole thing getting torn down prematurely
on.finalize (formally on.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)returnthis.args.input;});
should instead be
resource(({ on })=>{on.sync(()=>{syncCount++;return()=>cleanupCount++;});returnFormula(()=>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)
The text was updated successfully, but these errors were encountered:
Tasks
on.sync
on.cleanup
becomeson.finalize
(but keepon.cleanup
for compatibility)Lints
on.sync
+ return cleanup function() => return value
, because returning lazily accessed() => this.args.input
is fine, but returningthis.args.input
is not.Learning materials
on.sync
allows easy managing of reactive updates, no worry about the whole thing getting torn down prematurelyon.finalize
(formallyon.cleanup
) is tied to the lifetime of the parent contextNotes:
should instead be
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 thecreateCache
api (which is internal in the helper managers)The text was updated successfully, but these errors were encountered: