atomicojs / atomico

Atomico a micro-library for creating webcomponents using only functions, hooks and virtual-dom.
https://atomicojs.dev
MIT License
1.15k stars 43 forks source link

New useRefEffect hook with a new observability model for references #123

Closed UpperCod closed 6 months ago

UpperCod commented 6 months ago

New features.

useRefEffect

Observability for references?

Yes, now thanks to the useRefEffect hook, you can track the value transition of a reference through subscription. The goal is to leverage the mutable model of references and provide possibilities for better communication without rendering.

Is it reactive? No, since the subscriber is only useRefEffect. Therefore, you still need useProp, useState, or useUpdate to dispatch an update to the render or hooks external to useRefEffect.

Ref

Now, references are instances of a class. This is ideal for checking their type in certain interactions.

createRef

Allows you to create references external to the use of useRef. This is ideal for generating subscriptions to elements global to the component.

Environment improvements

  1. Type improvements
  2. Test improvements
  3. Update of devDependencies