For this reason, no separate effects are used when using $mol_wire. Instead, the same invariants are used that describe the usual reactive dependencies as well, but neither can change something on the side besides the return value. This gives a stable, predictable and manageable moment of applying side effects.
@memcount(next=1){returnnext}@memdoubleCount(){returnthis.count()*2}@memcountLog(){console.log('count',this.count())}@memdoubleCountLog(){console.log('doubleCount',this.doubleCount())}@memrender(){console.log('[')this.doubleCountLog()this.countLog()console.log(']')}@actmain(){// initialthis.render()// logs: [ 2 1 ]// change statethis.count(2)// no logsthis.count(3)// no logs// don't wait next framethis.render()// logs: 6 3// check memoizingthis.render()// no logs}
$mol_wire and MobX have similar exception behavior - they are transparent to them as [if there were no intermediate memoization and the computation starts from scratch every time they are accessed] - this gives a simpler mental model.
For this reason, no separate effects are used when using $mol_wire. Instead, the same invariants are used that describe the usual reactive dependencies as well, but neither can change something on the side besides the return value. This gives a stable, predictable and manageable moment of applying side effects.
Sandbox
$mol_wire and MobX have similar exception behavior - they are transparent to them as [if there were no intermediate memoization and the computation starts from scratch every time they are accessed] - this gives a simpler mental model.
Sandbox
Thanks this is good information. I appreciate you taking the time to explain.