refetchOnWindowFocus is not working
nitedani opened this issue · 3 comments
nitedani commented
Which @ngneat/query-* package(s) are the source of the bug?
query
Is this a regression?
No
Description
When setting refetchOnWindowFocus: "always", I expect the query to refetch when I click outside, then inside the window. That is how it works for me in react. It doesn't work here for some reason.
import { HttpClient } from '@angular/common/http';
import { Component, inject } from '@angular/core';
import { UseQuery } from '@ngneat/query';
@Component({
selector: 'app-root',
template: `<div>
<div *ngIf="pokemon.result$ | async as pokemon">
<p *ngIf="pokemon.isError">Error...</p>
<div *ngIf="pokemon.data">
<div *ngFor="let pokemon of pokemon.data.results">
<div>{{ pokemon.name }}</div>
</div>
</div>
</div>
</div>`,
})
export class AppComponent {
private useQuery = inject(UseQuery);
private http = inject(HttpClient);
getPokemon() {
return this.useQuery(
['pokemon'],
() => {
return this.http.get<{
results: { name: string; url: string }[];
}>('https://pokeapi.co/api/v2/pokemon');
},
{
refetchOnWindowFocus: 'always',
}
);
}
pokemon = this.getPokemon();
}
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in
No response
Anything else?
No response
Do you want to create a pull request?
No
luii commented
Yeah also tried this and it's not working, neither in Firefox nor in Chrome, so it's not Browser dependent.
NetanelBasal commented
👀
NetanelBasal commented
Can you check it with the latest version? It seems to work locally.