redux-toolkit icon indicating copy to clipboard operation
redux-toolkit copied to clipboard

Update documentation comment for invalidationBehavior

Open cainePW opened this issue 1 year ago • 2 comments

It seems the default value invalidationBehavior does not accurately reflect the documentation comment.

The comment describes the default value as immediately.

Looking at the default set of options here it seems the default value is set to delayed.

const optionsWithDefaults: CreateApiOptions<any, any, any, any> = {
      reducerPath: 'api',
      keepUnusedDataFor: 60,
      refetchOnMountOrArgChange: false,
      refetchOnFocus: false,
      refetchOnReconnect: false,
      invalidationBehavior: 'delayed',
      ...options,
      extractRehydrationInfo,

...

If I understand this correctly, the comment needs to be updated. Apologies if I've got this wrong!

Thanks for your hard work on this library!

cainePW avatar Aug 29 '24 19:08 cainePW

+1. This can cause issues with listeners that need to immediately respond to fulfilled queries. I had a scenario where it created an odd discrepancy where an API request succeeded but in the listener logic, the state wasn't up to date because the cache tags hadn't been invalidated (yet, because they were delayed).

Good find on the comment, thank you!

Kluskey avatar Oct 18 '24 03:10 Kluskey

Good spot - PRs welcome :)

EskiMojo14 avatar Oct 18 '24 09:10 EskiMojo14

Looks like this was fixed in #4555

markerikson avatar Nov 23 '24 21:11 markerikson