-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Description
This feature would allow async derived handlers to determine when they are invalid:
derived([a, b], async ([$a, $b], set, invalidate) => {
invalidate()
const [$a_, $b_] = await Promise.all([a_fn($a), b_fn($b)])
set($a_ + $b_)
})
This would also enable multi-step derived state machines without diamond dependency issues:
derived([a, b], async ([$a, $b], set, invalidate) => {
invalidate()
const $a_ = await a_fn($a)
set({ step: 1, $a_ })
invalidate()
const $b_ = await b_fn($b)
set({ step: 2, $a_, $b_ }
})
A con against this is that it would add an additional api item & will only be useful for async derived stores.
This idea originated from #3219 (comment)
Metadata
Metadata
Assignees
Labels
No labels