Re implement asset fetching

This commit is contained in:
Joseph Garrone
2024-06-05 06:10:11 +02:00
parent 89fb6de2d5
commit b1da684008
18 changed files with 182 additions and 234 deletions

View File

@ -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]
);
}