furkansarihan / firestore_collection

Firestore extension with cache-first pagination and stream builder support.
MIT License
9 stars 5 forks source link

Could this be used to stream a collection? #2

Closed xanf-code closed 3 years ago

xanf-code commented 3 years ago

The document changes are not being reflected in real time, or am i missing something?

azazadev commented 3 years ago

@xanf-code what is the error ? if you are talking about FirestoreCollection initialisation correct I think @furkansarihan forget to add collection field, you can configure like this

 FirestoreCollection fireCollection = FirestoreCollection(
    collection: FirebaseFirestore.instance
        .collection('posts')
        .doc('post_id')
        .collection("comments"),
    initializeOnStart: true,
    // first page will fetched immediately
    offset: 15,
    // page size
    serverOnly: false,
    // cache first
    live: true,
    // notifies to newest comments
    query: FirebaseFirestore.instance
        .collection('posts')
        .doc('post_id')
        .collection("comments"),
    orderField: 'timestamp',
  );

@furkansarihan please update doc

furkansarihan commented 3 years ago

@xanf-code This package designed for sequential data, for example messages.

If firestore_collection is ordered by timestamp filed of a message document;

New inserted documents can be listenable. (The documents has bigger timestamp value than, current bigger in firestore_collection)

Listen for document changes - [suggestion]

With all conditions above, document changes can be listenable.

Note: This approach could has some bugs caused missing documents on lazy-load.

I am currently investigating this approach and planning to make it stable.

xanf-code commented 3 years ago

This helped, thank you.