Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于piniaPluginPersistedStore的异步初始化问题 #1

Open
spianmo opened this issue Apr 26, 2024 · 0 comments
Open

关于piniaPluginPersistedStore的异步初始化问题 #1

spianmo opened this issue Apr 26, 2024 · 0 comments

Comments

@spianmo
Copy link

spianmo commented Apr 26, 2024

首先感谢您对pinia-persist库的贡献。我目前遇到一个piniaPluginPersistedStore的异步初始化问题,我注意到在使用了pinia-persist库之后store的加载是异步的,这意味着在store的存储没有初始化完毕前去取store里存储的值是取不到的,尽管对应的store具备响应式,我可以在加载完毕后拿到对应的值,但是我现在想做到同步等待store加载完毕,或者是获取到store加载完毕的回调,做对应的处理,我应该怎么做?
我观察到底层的数据存储使用了您的另一个库sunshine-storage 1.0.0-beta.6,有任何办法可以实现同步等待store加载完成或者获取到对应加载完毕的回调吗?
以下是我的应用场景,我做了一个默认设置页,用于存储一些默认的LLM对话配置,然后每一次新起新的会话时去store存储的默认配置中deepClone一份默认配置作为本次会话实例的LLM配置,这个过程发生在刷新页面后产生的路由变化后的onMounted阶段,由于store未加载完毕,我每次取到的永远是store里定义的默认值,由于业务特性,会话实例的配置应当在页面加载后的一瞬间完成深拷贝。

image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant