Skip to content

Overload cached for non-class use - #1218

Open
NullVoxPopuli wants to merge 3 commits into
emberjs:mainfrom
NullVoxPopuli:nvp/cached-overloaded
Open

Overload cached for non-class use#1218
NullVoxPopuli wants to merge 3 commits into
emberjs:mainfrom
NullVoxPopuli:nvp/cached-overloaded

Conversation

@NullVoxPopuli

@NullVoxPopuli NullVoxPopuli commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Sample implementation


Propose overloading @cached for non-class use

Summary

This pull request is proposing a new RFC.

To succeed, it will need to pass into the Exploring Stage, followed by the Accepted Stage.

A Proposed or Exploring RFC may also move to the Closed Stage if it is withdrawn by the author or if it is rejected by the Ember team. This requires an "FCP to Close" period.

An FCP is required before merging this PR to advance to Accepted.

Upon merging this PR, automation will open a draft PR for this RFC to move to the Ready for Released Stage.

Exploring Stage Description

This stage is entered when the Ember team believes the concept described in the RFC should be pursued, but the RFC may still need some more work, discussion, answers to open questions, and/or a champion before it can move to the next stage.

An RFC is moved into Exploring with consensus of the relevant teams. The relevant team expects to spend time helping to refine the proposal. The RFC remains a PR and will have an Exploring label applied.

An Exploring RFC that is successfully completed can move to Accepted with an FCP is required as in the existing process. It may also be moved to Closed with an FCP.

Accepted Stage Description

To move into the "accepted stage" the RFC must have complete prose and have successfully passed through an "FCP to Accept" period in which the community has weighed in and consensus has been achieved on the direction. The relevant teams believe that the proposal is well-specified and ready for implementation. The RFC has a champion within one of the relevant teams.

If there are unanswered questions, we have outlined them and expect that they will be answered before Ready for Release.

When the RFC is accepted, the PR will be merged, and automation will open a new PR to move the RFC to the Ready for Release stage. That PR should be used to track implementation progress and gain consensus to move to the next stage.

Checklist to move to Exploring

  • The team believes the concepts described in the RFC should be pursued.
  • The label S-Proposed is removed from the PR and the label S-Exploring is added.
  • The Ember team is willing to work on the proposal to get it to Accepted

Checklist to move to Accepted

  • This PR has had the Final Comment Period label has been added to start the FCP
  • The RFC is announced in #news-and-announcements in the Ember Discord.
  • The RFC has complete prose, is well-specified and ready for implementation.
    • All sections of the RFC are filled out.
    • Any unanswered questions are outlined and expected to be answered before Ready for Release.
    • "How we teach this?" is sufficiently filled out.
  • The RFC has a champion within one of the relevant teams.
  • The RFC has consensus after the FCP period.

NullVoxPopuli-ai-agent and others added 2 commits July 31, 2026 07:52
* Add RFC: Overload cached for non-class use

Derived-state companion to RFC 1071 (overloaded tracked). Re-uses the
Reactive/ReadOnlyReactive interfaces defined there; cached(fn, options)
returns a read-only CachedValue.


* Fill in proposal PR URL

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Do not conflate derived state with cached state

Derived state is just plain functions and needs no API; cached() is
opt-in memoization of a derivation. Reword Summary, Motivation, usage
headings, and How We Teach accordingly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Address review: guides link, drop terms paragraph, RFC 615 to appendix

- Motivation references the in-flight reactivity guides
  (ember-learn/guides-source#2219) instead of claiming docs are sparse
- remove the derived-vs-cached clarification paragraph (the guides
  cover it; not an ambiguation)
- move the RFC 615 relationship to the Appendix, without any
  de-emphasize/deprecate intent

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Address review: drop equals, drop 'memoization' wording

- remove the equals option from the proposed API entirely (calling fn
  is the expensive part; re-running it to discard the result is silly);
  noted as deferred in the Appendix
- say caching, not memoization, throughout
- reword the 'born a ReadOnlyReactive' sentence
- drop the implementation-would-be-lower aside

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Apply suggestion from @NullVoxPopuli

* Address review: get on ReadOnlyReactive, trim examples and mentions

- no new CachedValue interface; add get to ReadOnlyReactive instead
  (an RFC 1071 oversight) and return ReadOnlyReactive from cached()
- apply suggested guides sentence (drop 'over the years')
- Starbeam only in prior art; resources are a different concept
- remove the contrived nested-let template example

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: NullVoxPopuli-ai-agent <268630448+NullVoxPopuli-ai-agent@users.noreply.github.com>
Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
Comment thread text/1218-overload-cached-for-non-class-use.md
Comment thread text/1218-overload-cached-for-non-class-use.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants