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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initiate with forceRefetch not working as expected #58

Closed
lukascivil opened this issue Oct 23, 2023 · 2 comments
Closed

Initiate with forceRefetch not working as expected #58

lukascivil opened this issue Oct 23, 2023 · 2 comments

Comments

@lukascivil
Copy link

lukascivil commented Oct 23, 2023

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

image

Expected behavior

Initiate() with forceRefetch should run again and not bring old values from the cache. As a workaround, instead of calling another endpoint with initiate, I had to reimplement the other endpoint to avoid initiate.

Minimal reproduction of the problem with instructions

  1. Call another endpoint within an endpoint using forceRefetch to call again

What is the motivation / use case for changing the behavior?

The motivation is to call another endpoint, taking advantage of its entire construction, without having to rewrite it again.

Is this problem related to redux-toolkit or the ngrx-rtk-query lib? I have not validated pure RTK in another project.

Environment




Browser:
- [x] Chrome (desktop) 118.0.5993.89 (Versão oficial) 64 bits
 
For Tooling issues:
   "@angular-devkit/build-angular": "^16.2.4",
    "@angular-eslint/builder": "~13.0.1",
    "@angular-eslint/eslint-plugin": "~13.0.1",
    "@angular-eslint/eslint-plugin-template": "~13.0.1",
    "@angular-eslint/template-parser": "~13.0.1",
    "@angular/cli": "^16.2.4",
    "@angular/compiler": "^16.2.7",
    "@angular/compiler-cli": "^16.2.7",
    "@angular/language-service": "^16.2.7",
    "@ngrx/router-store": "^16.3.0",
    "@ngrx/store": "^16.3.0",
    "@ngrx/store-devtools": "^16.3.0",
    "ngrx-rtk-query": "^16.2.0",
    "@reduxjs/toolkit": "^1.9.6",
    "typescript": "~5.0.2"


@lukascivil
Copy link
Author

@SaulMoro Do not forget me.

@SaulMoro
Copy link
Owner

SaulMoro commented Nov 26, 2023

Is a problem relates to rtk-query reduxjs/redux-toolkit#2921 (comment)

Anyway, there are better ways to archive your goal:

  • Data normalization with entities and transformResponse (read rtk query documentation)
  • Invalidation tags manually with API.util.invalideTags use onQueryFullfilled or onQueryStarted (read rtk query documentation)
  • Use lazy queries and use query.state().currentData instead of data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants