Closed ArielGueta closed 1 month ago
you should have some guard in closure func
data = derivedAsync(() => this.id() ? this.service.get(this.id(): null), { requireSync: true })
Hello @ArielGueta
derivedAsync
uses effect
under the hood, and the effect
will wait until all the inputs are set and then call the callback function.
The issue comes from requireSync
that you have enabled. When you enable requireSync
it will synchronously call the callback function and it won't use the effect
scheduling (so it won't wait for your inputs).
So, this is working as expected.
Here's a repro: https://stackblitz.com/edit/stackblitz-starters-97u74t?file=src%2Fmain.ts
Hi
I have an issue with using derivedAsync and require input:
The issue is that when you call the callback in the first time this.id() will be undefined.