S
SolidJS•16mo ago
Abrinzer

delay execution of createEffect.

I have a use case where I want one of my createEffect to be called before another . Currently they are called one after the other. I want to swap the executing sequence.
13 Replies
Abrinzer
Abrinzer•16mo ago
Is it possible to do that. Or I am trying something weird over here. I have a very valid use case though.
REEEEE
REEEEE•16mo ago
Would help to see some code?
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Abrinzer
Abrinzer•16mo ago
createEffect(() => {
if (someCondition1) {
setQuantity(0);
}
});
createEffect(() => {
if (someCondition2) {
setQuantity(orderFlow.quantity);
}
});
createEffect(() => {
if (someCondition1) {
setQuantity(0);
}
});
createEffect(() => {
if (someCondition2) {
setQuantity(orderFlow.quantity);
}
});
no way to handle it without timer ?
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
REEEEE
REEEEE•16mo ago
So you want the condition2 effect to run first?
Abrinzer
Abrinzer•16mo ago
Yes correct condition1 to run first.
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Abrinzer
Abrinzer•16mo ago
both the condition can be true at the same time. I have not added the complete snippet here. Basically I want to keep them in separate effects to avoid unnecessary computation. But thanks I will look for a settimeout as a solution for now.
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Abrinzer
Abrinzer•16mo ago
😢 I don't want to use it . will find a better way eventually . Thanks for your help
REEEEE
REEEEE•16mo ago
The only other way is to have a third temporary signal that you update after the first condition and the effect for the second condition reads it
Abrinzer
Abrinzer•16mo ago
aah that makes sense
Want results from more Discord servers?
Add your server
More Posts