S
SolidJS•10mo ago
sgr

Integrating IndexedDB with Solid.js for Real-time Updates

Hello, I'm working on integrating IndexedDB with a Solid.js application. My objective is to display data from IndexedDB and ensure that any changes in the database are reflected in real-time within the app without manual refreshes. Here's a brief overview of my current approach: I've set up IndexedDB to store and retrieve data. I'm using Solid's createSignal to manage the state in the app. Whenever there's an update in IndexedDB, I manually fetch the updated data and update the Solid signal. While this method is functional, I'm curious if there's a more efficient or idiomatic way to achieve real-time updates in Solid.js when interfacing with external data sources like IndexedDB. Specifically: Is there a recommended pattern or best practice for integrating IndexedDB with Solid.js? Can I leverage Solid's reactive system to automate updates without having to fetch data manually after every IndexedDB change? Are there any community examples or resources that detail a similar integration?
4 Replies
ai6
ai6•10mo ago
You can use Dexie to create observables from queries: https://dexie.org/docs/liveQuery()
liveQuery()
The easiest way to use IndexedDB. A lightweight, minimalistic wrapper that provides a straightforward API for developers using IndexedDB.
sgr
sgr•10mo ago
Thanks a lot..Can you please suggest best practices for the Solid JS with Indexdb that would help me in setting up my code.
ai6
ai6•10mo ago
I can't think of anything specific about Solid and Indexeddb, just follow Solid best practices and Indexeddb best practices... Only open database once and reuse the connection, think about when you want to load your data, be mindful of where you perform updates, etc. You might want to check out solid-dexie I'm not currently using it but I might switch to it since it looks pretty nice
GitHub
GitHub - faassen/solid-dexie: Dexie integration for Solid
Dexie integration for Solid. Contribute to faassen/solid-dexie development by creating an account on GitHub.
sgr
sgr•10mo ago
Thank you this helpsđź‘Ť
Want results from more Discord servers?
Add your server
More Posts