proposal-signals / signal-polyfill

Implementation tracking the current state of https://github.com/tc39/proposal-signals
Apache License 2.0
185 stars 13 forks source link

Don't recompute when dependent signals come back to previous values used for last computation #15

Open divdavem opened 3 months ago

divdavem commented 3 months ago

This PR implements this suggestion to avoid triggering useless re-computations when dependent signals come back to their previous values used for last computation. It includes a cache of calls to the equals function to avoid calling multiple times the equals function for the same comparison.

littledan commented 3 months ago

This is a very interesting patch! I'm not ready to land it yet, as the memory usage tradeoff that @shaylew is not obvious. Let's discuss these alternatives in an issue. It's really excellent to have these alternative semantics implemented in a branch, for comparison.