Skip to content

add default value to resource and rxResource #58840

@robertIsaac

Description

@robertIsaac

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

No response

Description

I'm experimenting now with the new resource and rxResource new APIs and one thing that is a bit hassle is that it adds undefined to the the type of it
for example I find myself needing a lot to do resource.value() ?? [] because before I was making the signal value empty array till the value is loaded

Proposed solution

is to add initial value to the ResourceOptions
points to be discussed

  1. if hasValue() should be true or false if it's the initial value
  2. when resource.reload() is called if it should return to the default value or not

Alternatives considered

is to keep using ?? initialValue

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions