ConsoleTVs / sswr

🔥 Svelte stale while revalidate (SWR) data fetching strategy
MIT License
234 stars 11 forks source link

If `fetcher` returns `null` the revalidation is ignored #27

Open rauchg opened 2 years ago

rauchg commented 2 years ago

This was my fetcher function:

  async function readUser() {
    return localStorage.user ?? null;
  }

If I'd go to the console and run localStorage.removeItem('user'), revalidation of any kind (whether via calling revalidate or focus revalidation) wouldn't work, until I switched it to:

  async function readUser() {
    return localStorage.user ?? false;
  }
ConsoleTVs commented 2 years ago

Hey Guillermo,

Thanks A LOT for this exhaustive issue reports. I will be looking into them to see if they are related to this lib or https://github.com/ConsoleTVs/swrev.

I think I'll need some testing to be able to do all this, apologies!

Furthermore, I'm really happy to see you testing this tool. I'll keep an eye on all that's been posted around here for the upcoming release and see if I am able to correctly fix the use cases provided.

I know it might be frustrating to see many issues around. My intention was to build a foundation to be used across frameworks Like Svelte or Vue (You guys already have a great swr library for react). Strangely, I seem to be getting less issues on the Vue adapter (https://github.com/ConsoleTVs/vswr). Perhaps less people using it, no idea.

I am not an expect on Svelte, so I might need some help in some areas. Will investigate, thanks again!