Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add comparison of data via compare config #41

Open
darrenjennings opened this issue May 9, 2020 · 3 comments
Open

add comparison of data via compare config #41

darrenjennings opened this issue May 9, 2020 · 3 comments
Labels
help wanted Extra attention is needed swr

Comments

@darrenjennings
Copy link
Contributor

swr uses a compare function to detect changes to see if the cache needs to be updated. Would be a nice addition before setting the cache. vercel/swr#219

@darrenjennings darrenjennings added help wanted Extra attention is needed swr labels May 9, 2020
@bikingbadger
Copy link
Contributor

Trying to get involved in open source and would like to tackle this one. Might just need to pick your brain a bit to exactly understand what you mean. From what I understand you want the same functionality of using compare in swrv as it is in swr?

@darrenjennings
Copy link
Contributor Author

@bikingbadger yes we are looking to have some parity re: vercel/swr#655

  1. yarn add dequal
  2. add compare as a function to the config https://github.com/Kong/swrv/blob/master/src/use-swrv.ts#L43 with the default of import { dequal } from 'dequal/lite
  3. compare the values in the cache before setting the data here: https://github.com/Kong/swrv/blob/master/src/use-swrv.ts#L234
  4. add a test should allow use custom isEqual method similar to: https://github.com/vercel/swr/blame/a9c10f74963bbe3b566201ef9f43a2242440f0f1/test/use-swr-refresh.test.tsx#L250

@bikingbadger
Copy link
Contributor

Great. Thanks for the run down. I will start taking a look at it and working on a solution. Appreciate the help @darrenjennings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed swr
Projects
None yet
Development

No branches or pull requests

2 participants