question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatically expose promises when using firestore option

See original GitHub issue

It would be useful to be able to use the short firestore notation and still be able to access the promises, for usage with vue-promised for instance.

There are not a lot of situation where data is loaded asynchronously, and a loader indicator is not necessary.

i.e.

<template>
  <Promised :promise="$firestore.promised.todos">
	<!-- etc... -->
  </Promised>

  <Promised :promise="$firestore.promised.currentTodo">
	<!-- etc... -->
  </Promised>
</template>


<script>
new Vue({
  data: {
    // Usually an array for collection
    todos: [],
    // and null for documents
    currentTodo: null,
  },
  firestore: {
    todos: db.collection('todos'),
    currentTodo: db.collection('todos').doc('1'),
  },
})
</script>

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
pacific202commented, Apr 16, 2019

I believe that what we’re looking for is something parallel to the AngularFire $loaded event.

The computed method above works for me for now, but in future I’d like a single event to be fired when all vuefire promises have been resolved without the developer having to replicate all of the individual data variable names in a computed or created and maintain that list in two sections of the component.

I’d like to see this implemented as a vue lifecycle function that would get called when all vuefire calls have returned:

{
  data: function(){
    return {
      a: null,
      b: []
    }
  },
  firestore: {
     a: db.get('a'),
     b: db.collection('b')
  },
  firestore_loaded: function([err]) {
    // need to figure out the best way to trap zero or more errors here
  }
}
0reactions
posvacommented, Dec 21, 2022

FYI this is now possible with the composables useDocument() and others

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use the Cloud Firestore REST API - Firebase
The best way to begin experimenting with the REST API is to use the API Explorer, which automatically generates Google Identity OAuth 2.0...
Read more >
How to use React Hooks with Firebase Firestore
In this article, we'll learn how to combine Firestore with React Hooks for a simple and efficient grocery list app.
Read more >
Developing Real-Time Apps with Firebase and Firestore - Auth0
Learn how to develop a real-time web chat application with Firebase and Firestore with user registration and authentication secured with ...
Read more >
re-base - Firebase Open Source
Bind a collection to a state property in your component. When then collection changes in firestore, your component will re-render with the latest...
Read more >
Subscriptions in Apollo Server - Apollo GraphQL Docs
The second parameter is a filter function that returns true if a subscription update should be sent to a particular client, and false...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found