UNPKG

react-rv

Version:

react-rv is a lightweight and efficient state management library for React that allows you to create reactive variables and subscribe to them with minimal overhead.

2 lines 453 B
var u=(e,n)=>e===n;function s(e,n){let{eq:R=u,on:i}=n??{},o=new Set;i&&o.add(i);let T=(...t)=>{if(t.length===0)return e;let[r,p]=t,f=R;if(typeof p?.eq<"u"&&(f=p.eq===!1?u:p.eq),f(e,r))return e;let c=e;return e=r,o.forEach(l=>l(r,c)),e};return T.on=t=>(o.add(t),()=>{o.delete(t)}),T}s.fn=(e,n)=>s(e(),n);import{useSyncExternalStore as d}from"use-sync-external-store/shim";var m=e=>d(e.on,e,e);export{s as rv,m as useRv}; //# sourceMappingURL=index.js.map