Skip to content

Releases: tronikelis/solid-swr

v5.0.2

13 Dec 16:13
3a4f76a

Choose a tag to compare

What's Changed

Full Changelog: v5.0.1...v5.0.2

v5.0.1

28 Sep 13:10

Choose a tag to compare

Only type changes, when producing with a mutator, the previous data can be undefined

Full Changelog: v5.0.0...v5.0.1

v5.0.0

24 Sep 05:46
f811aff

Choose a tag to compare

V5 🔥

A complete rewrite of solid-swr mostly focused on performance

Real performance difference from v4

So I migrated my production app to v5 and here is the comparison

Before

image

After

image

How?

Basically v0-v4 were never fast anyway as every hook instance had to copy the cache

https://github.com/Tronikelis/solid-swr/blob/424e295a8c8fde642be95370cf96fed04517ee49/src/lib/index.ts#L81-L85

See the structuredClone, because of this when using useSWR intensively you will incur a lot of GC time which is not necessary

Plus notice the dequal call, this is a kinda patchy workaround to not clone everything everywhere, but only when actually needed, but dequal itself is expensive to call

V5 now has 0 dependencies and is about 1.5kb

Breaking changes

I recommend reading v5 readme as I've written everything there

There are a ton of breaking changes in this release, but that is necessary to make this library as I envision it to be

Store / Cache

Now solid-swr manages its own store, but you can hook into it and remove items at will (lru is provided with relevant hooks), more info in v5 readme

So isLoading, data, err is now in a single solid store for all keys

Core / Extra

Now hooks are separated into /core and /extra, all /extra hooks are created with using the /core hooks, that is you could have created all the /extra hooks yourself easily

So there now are 2 swr options SwrOpts and SwrFullOpts to completely separate core from extra, the latter is from extra

Prefer composition

In previous versions I just wrote everything in one function which was difficult to maintain and extend,
now in core you will find:

  • createRevalidator
  • createMutator
  • useSwr <- a "pure" minimal swr

These utils are the corner stone of everything, every /extra utils is using them

No more custom window events

Custom window events are removed, now solid itself manages syncing of the data, however this has some implications

For example, in v4 when you mutate, you send the event to the hooks which gets their options from where they were called,

in v5, when you mutate, the function itself changes the state, thus it can get incorrect options, that's why I recommend always passing in options when creating revalidators or mutators, or abstract this away somehow

useSwrMutation is removed

Although you can still easily in 30 lines create it yourself, I don't believe it is the right abstraction, as it gets confusing when you call update.revalidate() or update.populateCache, but you are actually changing some arbitrary keys

What's Changed

Full Changelog: v4.1.0...v5.0.0

v4.1.0

26 Jun 18:41
424e295

Choose a tag to compare

What's Changed

Full Changelog: v4.0.9...v4.1.0

v4.0.9

01 Jun 12:35
22685a0

Choose a tag to compare

What's Changed

  • [55] bound mutate unwrap + clone by @tronikelis in #56
  • [57] bound mutate now is actually just a wrapper for matchMutate by @tronikelis in #58

Full Changelog: v4.0.8...v4.0.9

v4.0.8

31 May 16:51
da78a20

Choose a tag to compare

What's Changed

Full Changelog: v4.0.7...v4.0.8

v4.0.7

31 May 10:24
5f4e5df

Choose a tag to compare

What's Changed

Full Changelog: v4.0.6...v4.0.7

v4.0.6

08 Apr 14:07
f4ca365

Choose a tag to compare

What's Changed

Full Changelog: v4.0.5...v4.0.6

v4.0.5

07 Apr 18:25
7301906

Choose a tag to compare

What's Changed

Full Changelog: v4.0.4...v4.0.5

v4.0.4

07 Apr 17:05
5187953

Choose a tag to compare

What's Changed

  • better cleanup + some extra race condition things by @tronikelis in #49

Full Changelog: v4.0.3...v4.0.4