Skip to content

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

@arlowhite

Description

@arlowhite

Describe the problem that you experienced

A Model can be converted to an Observable with either toObservable or outputToObservable. The JSDocs do not make it clear that they have different replay behavior. Though this is described in https://angular.dev/guide/signals/rxjs-interop#timing-of-toobservable

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

However, the toObservable JSDoc (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 want toObservable or outputToObservable.

Describe the actions that led you to experience the problem

I was using switchMap, which subscribes later, making replay a concern.

Describe what you want to experience that would fix the problem

toObservable JSdocs should mention replay.

outputToObservable JSdocs 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: docsRelated to the documentationcore: inputs / outputscross-cutting: signals

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions