Omnistac / zedux

:zap: A Molecular State Engine for React
https://Omnistac.github.io/zedux/
MIT License
344 stars 7 forks source link

fix(atoms): improve id generation; prevent selector with args cache reuse edge case #46

Closed bowheart closed 1 year ago

bowheart commented 1 year ago

Description

There's an edge case with AtomSelector id generation where if two different selectors have the same name and take the same params, they'll reuse the same cache. Improving the code responsible for this has been a tech debt item since the selectors graph rework, but this is the first time we've run into a problem from it.

Improve id generation in the IdGenerator. Make new selector references always generate a new base key id hash for their ids so no conflicts like this can happen in the future. Make ids smaller and more unique by using a radix of 36. Clean up some code, finally addressing this tech debt and fixing the cache reuse bug in the process.