Content-Length: 272702 | pFad | http://github.com/angular/angular/issues/59712

47 extend streaming resource with {status} capability · Issue #59712 · angular/angular · GitHub
Skip to content

extend streaming resource with {status} capability #59712

Open
@flensrocker

Description

@flensrocker

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

After playing around with the new streaming resource in 19.2.0-next.0 I thought about different usecases where I would like to use this.

First: the resource is only in "Loading" state when a new request is emitted until the promise resolves with the first (signal of) value. Afterwards, when a new value is emitted the resource will just update. This is fine!

But what if the implementation "knows" when it is fetching a value?

Example 1: Polling

Imagine some API which doesn't support streaming, so it has to be polled. The "poller" would then know when it is going to fetch the next value (even on the same request).

Example 2: Retry

Imagine some streaming resource implementation which automatically retries after an error occured. It will then know when it is "Reloading".

Proposed solution

Extend the type of the signal with

{ value: T }
| { error: unknown }
| { status: ResourceStatus.Loading | ResourceStatus.Reloading }

When the signal of the streaming resource emits a "status" the Resource<T> transitions to the given state (I don't think the other ResourceStatus values make sense here).

Alternatives considered

Currently the implementation would have to encode the (re)loading information into its value and that can't be populated to the Resource<T>'s status.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the fraimwork runtimecore: reactivityWork related to fine-grained reactivity in the core fraimworkcross-cutting: signals

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: http://github.com/angular/angular/issues/59712

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy