Here's a small recursive example:
const word = S.data('John')
const number = S.data(123)
S.root(() => {
S(() => {
if (word() == 'mary') {
number(number() + 1)
}
})
S(() => {
console.log(number())
})
})
word('blah')
word('mary')
word('foo')
It causes the first computation to run infinitely (until the error) because it reads and sets the number in the same computation.
What's you advice for these sorts of situations in general?
In this case, maybe the hypothetical user meant:
const word = S.data('John')
const number = S.data(123)
S.root(() => {
S(() => {
console.log(number())
})
})
S.on(word, () => {
if (word() === 'mary') {
number(number() + 1)
}
})
word('blah')
word('mary') // logs the new number
word('foo')
Curious to know in what sorts of cases we might run into the infinite recursion, and how to deal with it.
Here's a small recursive example:
It causes the first computation to run infinitely (until the error) because it reads and sets the
numberin the same computation.What's you advice for these sorts of situations in general?
In this case, maybe the hypothetical user meant:
Curious to know in what sorts of cases we might run into the infinite recursion, and how to deal with it.