TimLariviere / Fabulous-new

Fabulous v2 - Work in progress
https://timothelariviere.com/Fabulous-new/
Other
41 stars 3 forks source link

[Performance, Architecture] implement `dependsOn` from V1 or `memo` #18

Closed twop closed 2 years ago

twop commented 2 years ago

We need a way to cut off diffing. In V1 there was a clever trick that involved getting the location of a function type.

It does seem like a hack to me, but very clever! ^_^.

Unfortunately, we cannot directly port it to v2 due to new reconciler. For example it works with structs vs reference types.

So, we need a similar way to cut off diffing of a branch. Note that in that case diffing of a branch is going to be way slower than a few allocations, thus it is totally ok to use dynamic dispatch + heap allocated values there.

I would propose to store some data in ViewNode (seems like a good place for that) vs global weak map used in V1. That is how React and Elm do that (at least conceptually).