Visitar URL original
httpResouce reload not getting the latest request value for reload · Issue #60798 · angular/angular · GitHub
The Wayback Machine - https://web.archive.org/web/20250731200059/https://github.com/angular/angular/issues/60798
Skip to content

httpResouce reload not getting the latest request value for reload #60798

@sheikalthaf

Description

@sheikalthaf

Which @angular/* package(s) are the source of the bug?

common

Is this a regression?

Yes

Description

I want to use some signal values for httpResource for request, but want to avoid api call when the signal value changes. I want to recall the api only when the user click apply.

Previously used rxResouce with loader, on calling reload it calls the loader and gets the latest params value.

 // This works fine with reload
 readonly data = rxResource({
    loader: () => {
      const params = { username: this.username(), page: this.page() };
      return this.http.get('https://jsonplaceholder.typicode.com/posts', { params });
    }
  });


  // This request fn not getting called on reload
  readonly data = httpResource<MyData>(() => {
    const params = untracked(() => {
     // page and size changes frequently and want to avoid call on changes
      return { username: this.username(), page: this.page(), size: this.size() };
    });
    return { url: 'https://jsonplaceholder.typicode.com/posts', params };
  });

  apply() {
   // refetch the data only when user clicks reload
    this.data.reload();
  }

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw


Please provide the environment you discovered this bug in (run ng version)


Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtimecross-cutting: resourceIssues related to the newly introduced resource / httpResourceneeds: discussionIndicates than an issue is an open discussion

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions