Hi All,
I apologize if some of this stuff has been discussed (at length) before, but I haven’t touched much with remoteStorage modules in a few months, and just recently started working with the documents module for a demo, so I’m looking at this with new eyes. Some comments/questions…
Currently, it seems modules need a carry out a few steps that aren’t so clear.
- Issue a
release
onprivateClient
(don’t sync anything) - Issue a
release
onpublicClient
(don’t sync anything) - When a listing (subdir, or root of the module) is requested then
use
it (sync this) - Write a wrapper for the on() function to filter out events not applicable to this listing.
There are a few things that don’t really seem logical here
- Intent
Why are we defaulting to sync everything, only to initially unsync everything - which i’ve been told is the way you are supposed to do it - then pick and choose which paths to sync? That’s a very confusing paradigm.
- Filtering Events
Once you’ve indicated you’re only going to use, the module still needs to implement boiler plate code to filter a bunch of chang events that you’ve effectively already said you are not syncing and you don’t care about. You are defining the listener events based on the listing you’ve requested, so why are we sending (potentially) hundreds of document change events to a listing that’s not on the same path?
For example:
`
remoteStorage.claimAccess({documents:'rw'}).then(function () {
remoteStorage.displayWidget('remotestorage-connect');
remoteStorage.documents.init();
invoices = remoteStorage.documents.getPrivateList('invoices');
invoices.getAll().then(function (list) {
for (var key in list) {
App.addInvoice(list[key].content);
}
});
invoices.on('change', function () {
console.log('RS onChange fired!', arguments);
});
invoices.on('error', function () {
console.log('RS onError fired!', arguments);
});
});
`
That’s from a demo app I’m working on. Without the document module filtering the change events, I get one change event for every single document in the documents module. Even though I’ve release
d everything, and use
d just ‘invoices’.
It could save a ton of resources (think mobile devices) if the remoteStorage client library could be told at a more base level to ignore anything and everything not in this listing, because it’s all the app will be working with. This means the remoteStorage client and discard considering each file for a potential change event much earlier than sending them up the chain only to be filtered out at the module level. This also means clearer modules, and a clearer way of stating intent.
Interested in any thoughts.
-Nick