You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const{observable, autorun}=require("mobx");constmap1=observable.map();autorun(()=>{console.log('compute');console.log(map1.has('foo'))})console.log(0);map1.set('foo','1');// computesconsole.log(1);map1.set('bar','2');// no compute because 'bar' key is not involvedconsole.log(2);map1.set('foo','3');// no compute because existence of 'foo' unchangedconsole.log(3);map1.delete('foo');// computesconsole.log(4);console.log('==================')constmap2=observable.map();autorun(()=>{console.log('compute');console.log(map2.get('foo'));})console.log(0);map2.set('foo','1');// computesconsole.log(1);map2.set('bar','2');// no compute because 'bar' key is not involvedconsole.log(2);map2.set('foo','3');// computesconsole.log(3);map2.set('foo','3');// no compute because value unchangedconsole.log(4);
As reference, MobX is able to do the following:
I think it is done by internally caching the request: https://github.com/mobxjs/mobx/blob/6daafc4f7930f807dd047bae1be55938e95017e5/src/types/observablemap.ts#L115-L131
The text was updated successfully, but these errors were encountered: