Packages

lustre effects for maintaining application state in the hash fragment

Current section

Files

Jump to
Raw

src/ffi.mjs

export const setHash = (value) => {
if (globalThis.location) {
globalThis.location.hash = value;
}
};
export const getHash = () => globalThis.location?.hash ?? "";
export const listen = (dispatch) => {
dispatch(getHash());
return globalThis.addEventListener("hashchange", () => {
return dispatch(getHash());
});
};