[TMP 2] Plugins system. support directory structure and store system.(the plugin needs build at each project)

This commit is contained in:
Sakamoto Shiina
2025-03-08 18:43:56 +09:00
parent 22ada89fa6
commit 48c6e7d69f
5 changed files with 59 additions and 42 deletions

View File

@@ -0,0 +1,22 @@
const store_hooks = {};
export const initStore = (createAtomWithHook) => {
Object.assign(store_hooks, {
useStore_CountPluginState: createAtomWithHook(
{ count: 10 },
"CountPluginState"
).useHook,
useStore_AnotherState: createAtomWithHook(
{ value: "initial" },
"AnotherState"
).useHook,
});
};
export const useStore = (hook_name) => {
if (!store_hooks[hook_name]) {
throw new Error(`Hook ${hook_name} is not initialized.`);
}
return store_hooks[hook_name]();
};