igorkamyshev / farfetched

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

Query Invalidation #481

Open domosedov opened 7 months ago

domosedov commented 7 months ago

Provide the ability to mark queries as invalid

ref

tanstack/query

example api

invalidate(query, {
  triggers: [ev1, ev2]
})

invalidate([query1, ...queryN], {
  triggers: [ev1, ev2]
})

or

invalidate({
  queries: [query1, ...queryN],
  triggers: [ev1, ev2]
})

use case

Update query after next query.refresh method call

// Case 1 without invalidate
page_1_opened -> refresh query1
page_2_opened -> some mutations
page_1_opened -> refresh query1 // return old data

// Case 2 with invalidate
page_1_opened -> refresh query1
page_2_opened -> some mutations -> invalidate query1
page_1_opened -> refresh query1 // return fresh data