hoodiehq-archive / hoodie-plugin-global-share

⛔ deprecated
12 stars 6 forks source link

hoodie.global.on doesn't work #20

Open spinningarrow opened 9 years ago

spinningarrow commented 9 years ago

If I add a hoodie.global.on('add', callback) statement in my JS file, and then do hoodie.store.add(<something>).publish() from a different browser session/user, the callback doesn't actually get called. What am I doing wrong?

gr2m commented 9 years ago

@spinningarrow could you show me the code with the .publish() call? Can you make sure that it succeeds by doing something like

hoodie.store.add(<something>).publish()
.fail(function(error) {
  console.log(error)
});
spinningarrow commented 9 years ago

I did something similar:

hoodie.store.add(<something>).publish().then(function () { console.log('success'); }, function () { console.log('error'); })

and didn't see error.

The funny thing is, if I run hoodie.global.sync() in the devtools console, I suddenly see all the documents that I should have (and then the updating continues if new documents are created).

gr2m commented 9 years ago

hmm odd. This should make sure that hoodie.global listens to changes, but it seems that this doesn't work here from some reason. I'm a bit flooded with work right now, I wish I could help you better debugging this.

Could you try to put in another hoodie.global.connect() call after the hoodie.global.on('add', callback) line?

myguidingstar-zz commented 8 years ago

I had the same problem and got it fixed with hoodie.global.connect(). Btw, hoodie.global('some-type').connect() doesn't work