swr icon indicating copy to clipboard operation
swr copied to clipboard

(WIP) Adding hash config

Open msdrigg opened this issue 3 years ago • 4 comments

Adding a function to the configuration to replace stableHash.

This pr is meant to resolve issues discussed in #1846.

It adds a hash function in the configuration that defaults to stableHash.

I haven't written any tests for this, but I have tested this on my personal repository and seen that it works. Can anyone please take a look at this and give me some direction on how to make this ready to merge?

E.g.:

  • what tests should I write?
  • Am I missing any places I should put the default configuration
  • This changes the signature of serialize. Should I make the hash function in serialize optional and make it defualt to stableHash internally?

msdrigg avatar Apr 17 '22 22:04 msdrigg

Seeing the errors, and this needs some work. Will resolve issues next week

msdrigg avatar Apr 17 '22 23:04 msdrigg

Do you need any support here? :)

psteinroe avatar Apr 21 '22 11:04 psteinroe

I have kind of stalled out here. Having a busy week with work and I am out of town this weekend. If anyone wants to take over this, I would not mind at all because I won't be able to get this resolved for at least another week.

There is a lot of work that needs to be done to change the signature of serialize. It might be a better approach to make serialize overridable rather than customHash, but I am not sure if that would work.

msdrigg avatar Apr 21 '22 15:04 msdrigg

I have made an attempt here https://github.com/vercel/swr/pull/1940 but a few tests are failing.

psteinroe avatar Apr 25 '22 07:04 psteinroe