Open NazariiShvets opened 1 year ago
It works for createJsonQuery
, so I think we should back port this feature to creteQuery
as well.
So, it's more complicated 🤔
What if we replace the handler of a Query during fork
?
const q = createQuery({
effect: () => Promise.resolve([])
})
const scope = fork({
handlers:[[q.__.executeFx, (p) => return [p]]]
})
We cannot skip params in this case, it would be harmful. So, we have to check usage of params in runtime.
I suggest you just remove params in sample
by fn
. Something like this 👇
const getDataQuery = createQuery({
effect: () => Promise.resolve([])
})
sample({
clock: pageOpened // Event<{ params: { id: '1' }, query: {} }>
fn: () => null,
target: getDataQuery.start
})
sample({
clock: pageUpdated // Event<{ params: { id: '2'}, query: {} }>
fn: () => null,
target: getDataQuery.start
})
We will think about improving DX in this case later 🙏
Precondition: docs
This design desigion does not take into account pattern within effector community with sample: If EventPayload of target is void, user can pass data in any shape without any warning, thus it can be unintuitive, why they hit cache miss on, for example, page route params refetch