S
SolidJS•2y 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
AbrinzerOP•2y 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•2y ago
Would help to see some code?
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Abrinzer
AbrinzerOP•2y 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•2y ago
Message Not Public
Sign In & Join Server To View
REEEEE
REEEEE•2y ago
So you want the condition2 effect to run first?
Abrinzer
AbrinzerOP•2y ago
Yes correct condition1 to run first.
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Abrinzer
AbrinzerOP•2y 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•2y ago
Message Not Public
Sign In & Join Server To View
Abrinzer
AbrinzerOP•2y ago
😢 I don't want to use it . will find a better way eventually . Thanks for your help
REEEEE
REEEEE•2y 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
AbrinzerOP•2y ago
aah that makes sense
Want results from more Discord servers?
Add your server