salsita / prism

React / Redux action composition made simple http://salsita.github.io/prism/
496 stars 24 forks source link

Performance #63

Open ccorcos opened 7 years ago

ccorcos commented 7 years ago

Doesn't this entirely destroy the laziness of React components?

https://github.com/salsita/redux-elm/blob/master/src/forwardTo.js#L14

I've come up with an interesting solution here:

https://github.com/ccorcos/elmish/blob/narrative/src/tutorial/7-lazy-react/index.js#L55-L63

Where I use shouldComponentUpdate to compare dispatch functions using a .equals function that remembers all the partially applied types...

tomkis commented 7 years ago

Yeah, forwardTo indeed returns a new reference.

However, I am not really fan of storing memoized function arguments in the function reference itself. I could imagine _.memoize could do the trick.

We have to decide how we want to handle this, because I do believe that this kind of performance optimization should be in user land.

ccorcos commented 7 years ago

_.memoize doesnt clean up though. you'll have a memory explosion.