Re implement asset fetching
This commit is contained in:
@ -5,15 +5,15 @@ import type { StatefulObservable } from "../StatefulObservable";
|
||||
/**
|
||||
* Equivalent of https://docs.evt.land/api/react-hooks
|
||||
* */
|
||||
export function useRerenderOnChange($: StatefulObservable<unknown>): void {
|
||||
export function useRerenderOnChange(obs: StatefulObservable<unknown>): void {
|
||||
//NOTE: We use function in case the state is a function
|
||||
const [, setCurrent] = useState(() => $.current);
|
||||
const [, setCurrent] = useState(() => obs.current);
|
||||
|
||||
useObservable(
|
||||
({ registerSubscription }) => {
|
||||
const subscription = $.subscribe(current => setCurrent(() => current));
|
||||
const subscription = obs.subscribe(current => setCurrent(() => current));
|
||||
registerSubscription(subscription);
|
||||
},
|
||||
[$]
|
||||
[obs]
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user