Dexie Live查询和服务工作者
我想在服务工作者中使用Dexie同步我的数据。 我也想在React Frontend中使用UseliveQuery Hook。
如果新数据写在服务工作者线程中,Dexie会自动更新查询吗?
I want to use Dexie within the service worker to sync my data.
I also want to use useLiveQuery hook in the React frontend.
Would Dexie automatically update the query if new data gets written in the service worker thread?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
如果您的服务工作者将数据写入数据库,则将立即通知React Frontend并相应地进行更新。通过广播通道进行沟通。如果使用缺乏广播渠道支持的旧式野生动物园浏览器,Dexie会有后备,以便使用PostMessage()在服务工作者中进行的突变。这一切都是由Dexie本身照顾的。
If data is written to the database by your Service worker, the React frontend will be notified instantly and update accordingly. Communication goes via BroadcastChannel. If using a legacy Safari browser that lacks BroadcastChannel support, dexie has a fallback so that mutations done in the service worker will be communicated using postMessage(). This is all taken care of by dexie itself.