Files
ncd-fe/packages/pl-fe/src/globals.ts
marcin mikołajczak 97d1ce2f47 pl-fe: Complete migration of settings store
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-10-07 18:37:50 +02:00

26 lines
660 B
TypeScript

/**
* globals: do things through the console.
* This feature is for developers.
*/
import { changeSetting } from 'pl-fe/actions/settings';
import type { Store } from 'pl-fe/store';
/** Add PlFe globals to the window. */
const createGlobals = (store: Store) => {
const PlFe = {
/** Become a developer with `plFe.isDeveloper()` */
isDeveloper: (bool = true): boolean => {
if (![true, false].includes(bool)) {
throw `Invalid option ${bool}. Must be true or false.`;
}
store.dispatch(changeSetting(['isDeveloper'], bool) as any);
return bool;
},
};
(window as any).plFe = PlFe;
};
export { createGlobals };