You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let { id }: IDProp = $props();
let orgPromise = $derived(getOrg(id));
const getOrgTask = task(async (param: number) => {
waittimeout(200);
returnawaitgetOrg(id);
});
let orgTask = $derived(getOrgTask.perform(id));
if I jus do getOrgTask.perform(id), then when id change I always get the same org
Hi...the return value of the task function it's already a store and kinda reactive by itself. The return value of the perform function is the task instance but you likely want to access the result from the orgTask store itself. If you want to instantiate a new task everytime the prop change you likely want to have the whole task function in the derived like this
<script>
let { id }: IDProp =$props();let orgTask =$derived.by(()=>{// you want to have an explicit dependency on id since it will not be picked up// by the reactivity system within the async function inside task. id;returntask(async (param:number) => { wait timeout(200);returnawaitgetOrg(id); }); });
</script>
Keep in mind that you are creating a new task everytime id changes so i don't know if that's exactly what you need. If you have an example of what you want to achieve i can probably help you :)
getOrgTask.perform(id)
, then when id change I always get the same orgThe text was updated successfully, but these errors were encountered: