dai-shi / proxy-memoize

Intuitive magical memoization library with Proxy and WeakMap

Home Page:http://proxy-memoize.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: Can proxy-memoize hand IF statements ?

jtwigg opened this issue · comments

Example

const fn = memoize(obj => {
  if(obj.test > 10) { 
      return obj.a
  } else {
      return obj.b
  }
});

given that the value's that are "touched" are conditional, obj.b can't be known to be accessed by magical recursive walk that's performed?

Will this cause inconsistencies?

Yes, it can handle conditional cases.
"touched" (we call it "affected") is rebuilt from empty on re-evaluation.
It's not that magical.