-
Notifications
You must be signed in to change notification settings - Fork 10
clear cache_
(clear-cache!)
Respo has two copies of caches inside for the purpose of:
- DOM diffing
- speed up rendering
The first one is easy to understand since virtual DOM is corresponding to the DOM we currently see in the page. That's why it's cached.
The second one is for rendering, maybe I should explain it in shouldComponetUpdate
-like process. Most times this virtual DOM is same with the previous one for diffing. But during hot code swapping, it's not. DOM state is updated, however, caches should be removed. That's why there's a second one.
clear-cache!
is to clear the second cache, during hot swapping.
Internally Respo is using memof, which is like momization just for Respo, for caching. It caches per component/plugin like caching a function with arguments. When comp-x
is called with same arguments is a very short period, it's likely to reuse caches. Each cache entry is roughly outdated after hundreds of render loops.