nitropage
Version:
A free and open source, extensible visual page builder based on SolidStart.
13 lines (11 loc) • 338 B
text/typescript
import { Accessor, untrack } from "solid-js";
/**
* Returns an accessor that is only reactive when the value changes from false to true
*/
export const createSimplex = (fn: Accessor<boolean>, invert = false) => {
return () => {
const state = untrack(() => fn());
if (state === !invert) return state;
return fn();
};
};