maxnowack / signaldb

SignalDB is a local JavaScript database with a MongoDB-like interface and TypeScript support, enabling optimistic UI with signal-based reactivity across multiple frameworks. It integrates easily with libraries like Angular, Solid.js, Preact, and Vue, simplifying data management with schema-less design, in-memory storage, and fast queries.
https://signaldb.js.org/
MIT License
276 stars 11 forks source link

Collection Dispose/Unregister #960

Closed psicomante closed 2 weeks ago

psicomante commented 3 weeks ago

Hello Max,

What do you think about adding a method to dispose/unregister a persistance adapter? E.g. (i'm very dubious about naming)

// src/Collection/index.ts

// Collection Class, adding method:
public async unregisterPersistenceAdapter() {
  await this.persistenceAdapter?.unregister()
}

Reason: we should allow unloading resources for collections requiring session and connection / disconnection workflow (such as IndexedDB). Moreover I am developing a IndexedDB adapter that sync multiple tabs through BroadcastChannel and it requires a close() function to disconnect the channel from receiving messages.

maxnowack commented 2 weeks ago

I‘ll Work on this soon. Closing as duplicate of #944 🙂