farfetched icon indicating copy to clipboard operation
farfetched copied to clipboard

Expose / Provide Event to mutate cached data

Open th3l0g4n opened this issue 1 year ago • 0 comments

It would be great if the cache method could return an event with wich it would be possible to set cache data directly. This should work the same way how tanStackQuery.setQueryData works.

For Example:

const customerQuery = createQuery(...)
const { setCacheData } = cache(customerQuery, ...)

customerQuery.$data // { firstname: 'John', lastname: 'Doe' }

setCacheData({ firstname: 'John', lastname: 'Malkovich' })
customerQuery.$data // { firstname: 'John', lastname: 'Malkovich' } <-- $data reflects updated cache

th3l0g4n avatar Aug 29 '24 13:08 th3l0g4n