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 ourterms of serviceand privacy statement.We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify toObservable VS outputToObservable replay behavior (in JSDoc) #57224

Open
arlowhiteopened this issue Aug 1, 2024 · 1 comment
Open
Labels
area: docs Related to the documentation core: inputs / outputs cross-cutting: signals P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Milestone

Comments

@arlowhite
Copy link

Describe the problem that you experienced

AModelcan be converted to anObservablewith eithertoObservableoroutputToObservable.The JSDocs do not make it clear that they have different replay behavior. Though this is described inhttps://angular.dev/guide/signals/rxjs-interop#timing-of-toobservable

toObservable uses an effect to track the value of the signal in a ReplaySubject.

However, thetoObservableJSDoc (docs you see in IDE) only say:

The signal's value will be propagated into the Observable's subscribers using an effect.

Enter the URL of the topic with the problem

No response

Describe what you were looking for in the documentation

Function JSdocs that help me decide whether I wanttoObservableoroutputToObservable.

Describe the actions that led you to experience the problem

I was usingswitchMap,which subscribes later, making replay a concern.

Describe what you want to experience that would fix the problem

toObservableJSdocs should mention replay.

outputToObservableJSdocs should note that the Observable does not replay.

Add a screenshot if that helps illustrate the problem

No response

If this problem caused an exception or error, please paste it here

No response

If the problem is browser-specific, please specify the device, OS, browser, and version

No response

Provide any additional information here in as much as detail as you can

No response

@JeanMeche JeanMeche added cross-cutting: signals area: docs Related to the documentation labels Aug 1, 2024
@ngbot ngbot bot added this to theneedsTriagemilestone Aug 1, 2024
@devversion
Copy link
Member

Agreed we should clarify this. Should be an easy addition to the JSDoc/written documentation.

I think there are two key points:

  • outputToObservableis creating an observable that represents the stream of "events firing" in an output.
  • toObservableconverts a signal that reflects state, hence subscribing viaReplayObservablemakes sense as initial emit to reflect the "current state"

@bencodezen bencodezen added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Aug 1, 2024
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: docs Related to the documentation core: inputs / outputs cross-cutting: signals P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

5 participants