Check out this example:
import {state, effect, memo} from '@fluid/core'
const count1 = state(0)
setInterval(() => count1.val++, 1000)
const count2 = state(0)
setInterval(() => count2.val++, 100)
const bool = state(true)
setInterval(() => bool.val = !bool.val, 2000)
console.log('start ----------------------------- ')
effect(() => {
if (bool.val) {
count1.val
console.log('a')
} else {
count2.val
console.log('b')
}
})
When the conditional branch changes to the false side, count2 should be the new dependency triggering the effect.
CodePen:
https://codepen.io/trusktr/pen/KwPjOWo/ea2c637ac0b6661ff4fbe6458984a338
The Solid.js version shows the expected behavior:
https://codepen.io/trusktr/pen/qEWzePW/3cd3eb4ea0e34551a597c9d3b08047c4
Check out this example:
When the conditional branch changes to the
falseside,count2should be the new dependency triggering the effect.CodePen:
https://codepen.io/trusktr/pen/KwPjOWo/ea2c637ac0b6661ff4fbe6458984a338
The Solid.js version shows the expected behavior:
https://codepen.io/trusktr/pen/qEWzePW/3cd3eb4ea0e34551a597c9d3b08047c4