igorkamyshev / farfetched

The advanced data fetching tool for web applications
https://ff.effector.dev
MIT License
186 stars 34 forks source link

Expose / Provide Event to mutate cached data #508

Open th3l0g4n opened 2 weeks ago

th3l0g4n commented 2 weeks ago

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