Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty store after signing in #148

Open
kevinmerckx opened this issue Apr 17, 2017 · 4 comments
Open

Empty store after signing in #148

kevinmerckx opened this issue Apr 17, 2017 · 4 comments

Comments

@kevinmerckx
Copy link

I am trying to display the documents stored in the db after the user signs in. For some reason, there are no documents right after signing in, even though I wait for the connect to be fired to call findAll

Scenario:

  • user signs in
  • we wait for a connect event on the store to do a hoodie.findAll
  • the array is always empty
  • if we do another call to hoodie.findAll after, we actually get the documents

Is there something I'm missing to make this work?

@gr2m
Copy link
Member

gr2m commented Apr 18, 2017

can you try this please?

hoodie.account.signIn(options)
  .then(() => hoodie.store.pull())
  .then(() => {
    hoodie.store.findAll() // should now resolve with all documents
  })

After sign in, hoodie pulls all documents from the user’s account. We emit the signin event right away and resolve the promise from hoodie.account.signIn() before the pull finished, as it might take some time. But you are not the first to be confused by that behavior, we are looking for a simple way to sign in and know when the initial bootstrap finished

@kevinmerckx
Copy link
Author

Thanks for you quick reply @gr2m! My current workaround was indeed to do a hoddie.store.sync() when getting the signin event. Wouldn't an event store:synced be a good option to solve that problem?

@gr2m
Copy link
Member

gr2m commented Apr 18, 2017

There is already a pull event, but problem is that it emits after each pull. The way I resolve this myself is that after sign in I show the app and then populate the UI as new data gets added to the store

@kevinmerckx
Copy link
Author

Hm, I see. With a debounce, just in case :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants