@virtualstate/examples
Version:
41 lines • 955 B
JavaScript
// @abstract
import { hmm } from "./hmm.js";
export const DoneSymbol = Symbol("Done");
export const DefaultContext = {
globalThing: 0
};
function noop() {
return undefined;
}
export function useState(defaultState, state) {
if (state) {
return [state.source, noop];
}
return [
defaultState ?? hmm["👀"](),
noop
];
}
export function useEffect() {
}
export function useContext() {
return DefaultContext ?? hmm["👀"]();
}
export function useRef(value) {
const [state] = useState({
references: [],
index: -1
});
const index = state.index = state.index + 1;
const references = state.references;
if (isIndexedReference(references)) {
return references[index];
}
else {
return references[index] = { current: value };
}
function isIndexedReference(value) {
return !!value[index];
}
}
//# sourceMappingURL=source.interface.js.map