remotestorage / remotestorage.js

⬡ JavaScript client library for integrating remoteStorage in apps
https://remotestoragejs.readthedocs.io
MIT License
2.31k stars 141 forks source link

Allow to use multiple instances of remoteStorage #991

Open galfert opened 7 years ago

galfert commented 7 years ago

At the moment it's only possible to create one single instance at a time.

To allow to use multiple instances, we need to support some kind of namespace for the config in localStorage and the local cache (i.e. indexedDB) to avoid collision.

galfert commented 6 years ago

Do you think this should already be part of the 1.0 release or is it ok to have it in a later release (e.g. 1.1)?

raucao commented 6 years ago

In my opinion, this might get a bit tricky and require some design decisions about how to mark the various instances and then re-initialize them on startup. We can't use the user address, because connecting a storage is not a requirement.

As we will probably want to keep the lib backwards-compatible with just using a single unnamed instance (which I think is totally fine for most apps), I think this should be in 1.1 or later. Basically whenever someone contributed it, and it's merged and ready to use.

galfert commented 6 years ago

@gregkare pointed out that the way we are using the config object from config.js, it's currently also shared between multiple remoteStorage instances. That's another thing that needs to be changed.

fiatjaf commented 6 years ago

What about optionally letting the app specify the name of the IndexedDB database on instantiation (new RemoteStorage({name: 'rs-cache-foo'}))?

raucao commented 6 years ago

Good idea. But how would another app use the same DBs/prefixes then? Or maybe that's not necessary for those use cases?

galfert commented 6 years ago

But how would another app use the same DBs/prefixes then?

Apps only have access to their own IndexedDB databases anyway.

raucao commented 6 years ago

Oh wow, that was a big ole brainfart of mine! What was I thinking?

So that makes it a viable solution then, correct?

galfert commented 6 years ago

Yes, I was thinking pretty much of the same thing. Can't see anything that wouldn't work with that solution atm.