is this ok? import { Observable } from "../Kinds/Kinds"; const Render = <E extends…
Jump to turn (9)
- 1is this ok? import { Observable } from "../Kinds/Kinds"; const Render = ( thunk:
- 2theres no need for unsubscribe because there can only be one subscriber
- 3can u add unit tests for it using this test runner import { PrettyPrint } from "
- 4is the testing utility good?
- 5whats the point of mocking frameworks?
- 6make a timeout function that can be awaited
- 7is it worth making it in its own module?
- 8if iseven deservs own package then this too
- 9is this ok? const MockObservable = class { observer = () => {}; sub(f: (s: unkno
- User
is this ok? import { Observable } from "../Kinds/Kinds";
const Render = ( thunk: () => E, observables: Observable<unknown, unknown, unknown>[], ): E => { let res = thunk(); const l = observables.length;
const RENDER = () => { const next = thunk(); if (next instanceof HTMLElement && res instanceof HTMLElement) { res.parentNode?.replaceChild(next, res); } res = next; };
for (let i = 0; i < l; i++) { const h = observables[i]!; if ("sub" in h && typeof h.sub === "function") { h.sub(() => requestAnimationFrame(RENDER)); } }
return res; };
export { Render };
- Assistant