[Update/bugfix] Plugins: For development, fix hot reload issue that was restart every time updated the files.
This commit is contained in:
22
src-ui/plugins/plugin_examples/store/store.js
Normal file
22
src-ui/plugins/plugin_examples/store/store.js
Normal 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]();
|
||||
};
|
||||
Reference in New Issue
Block a user