tracks last subscribed component key reference, each time component subscribes value be incremented, and such incremented value be used as key under which component will be subscribed
will use {@see lastSubscribedComponentKey} and put under it {@see ISubscribedEntry}
state version be incremented on each update each time component renders, it's entry be updated with the version of this state. when it comes to decision if component should be updated, the version of update be compared to last rendered version, if they're same, or rendered version is bigger than state version it will be skipped. effectively this insures that component be updated exactly once for each version, preventing rerendering for e.g. nested components subscribed for same state.
returns next id for subscriber. Internal id is incremented
each update increments the version. this can be used for e.g. preventing unnecessary rerenders
and puts ISubscribedEntry under subscriber's id it in subscribedEntries
exists for cases when you need to override it.
subscribes component to this state represented by extending instance, behind the scenes will call useState using someNumber as it's initial state. the updateState from called useState and supplied options, will be stored under generated key on subscribed entries (simple object on this instance), any time update is called, all entries be traversed and corresponding update func be called, leading to update. on unmount entry will be deleted by the key it was subscribed under.
as options may be passed:
updateDeps?: a function that returns an array of dependencies. Before the next update, same func be called, and it's contents compared against the result of previous call. If both are same, update will be ignored onUnsubscribed?: any cleanup function on component's unmount. options are optional
Generated using TypeDoc
subscribes components calling use() on instance of it, anytime update is called will rerender each subscribed component. on component unmount, the component will automatically be unsubscribed.
use