ConsoleTVs / sswr

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

Problem: On update SWR was not refetching new data #33

Closed mgarf closed 1 year ago

mgarf commented 2 years ago

Solution: Migrate the subscription from onMount to beforeUpdate.

Theory: onMount is too early in the lifecycle for reactivity

ConsoleTVs commented 2 years ago

Is beforeUpdate also called before first render?

mgarf commented 2 years ago

Based on my testing and this: https://svelte.dev/tutorial/update

I wouldn't merge this yet though. I've barely tested it outside of ensuring it fixed my use case. I wanted it created so others can test out the changes as well

ConsoleTVs commented 2 years ago

Awesome, will wait a bit. Happy you could step in on this!

mgarf commented 2 years ago

Np, if your ok with it - I would like to add some playwright tests with a dummy sveltekit that runs through some sequences

ConsoleTVs commented 2 years ago

@mgarf Any news?

mgarf commented 2 years ago

been buried, should have time this week

marekdedic commented 1 year ago

Hi, I can confirm this PR fixes #24 for me, thanks

Is there anything else to do before the PR can be merged? I have tested this both on the README example as well as a medium-size real-world application, is there anything else? :)

ConsoleTVs commented 1 year ago

@marekdedic Can yo u check the conflicts I fixed on src/sswr.ts? If so, this is ready for merge

marekdedic commented 1 year ago

Umm, you mean 3d5a618? That should cause no problems... Or do you mean something else?

ConsoleTVs commented 1 year ago

I'll make a release in a few min/h