remoteStorage

All changes at once


#21

ah right. yes, there’s no event for that, might be worth introducing.

last time i tested with my messaging app it received 2000 local events in 8 seconds, so yes it does become quite slow when you start using it for anything more serious.

especially if you want one small specific item, which would have been superquick to fetch in 0.8.3 and now have to wait for all the other events to come by…


#22

If you want a specific item you can use getObject and that should fetch that one first and fulfill the promise as soon as it’s fetched instead of waiting for the whole tree to be synced.


#23

actually it’s not as slow as that by itself, of course it gets slower if you for instance call console.log for each local change event.

FWIW, I’m now using the following code as a work-around for this issue:

var timer;
remoteStorage.scope('/').on('change', function() {
  if(timer) {
    clearTimeout(timer);
  }
  timer = setTimeout(function() {
    showEmail();
  }, 250);
});

Here showEmail() is the function which will only work after the relevant local events have all been fired.

The remoteStorage.scope('/') is an insider trick to get a baseclient without defining a module :wink:


#24

How do you know the “relevant” events have been fired? Why 250 ms?


#25

Continued here: https://github.com/remotestorage/remotestorage.js/issues/732

remoteStorage.sync's “done” event seems to do what I want.