Skip to content

Bug: doc(...).snapshotChanges does not return DocumentChangeAction #1762

Closed

Description

@Bielik20

Version info

Angular: 6.0.3

Firebase: 5.1.0

AngularFire: 5.0.0-rc.11

Other: Windows 10, browser (chrome)

How to reproduce these conditions

Subscribe to any DOCUMENT with "snapshotChanges". Eg:

this.afs.collection('myCollection').doc('myDocId')
  .snapshotChanges()
  .pipe(tap(res => console.log(res))
  .subscribe()

Debug output

image

Expected behavior

According to documentation snapshotChanges should return Observable<DocumentChangeAction<T>>.

Actual behavior

What it does return is Observable<Action<DocumentSnapshot<T>>>. type field is always "value" even if I delete record and payload does not seem to contain actual data (I was not able to find it).

Remarks

snapshotChanges works well on collections returning Observable<DocumentChangeAction<T>[]>. Problem occurs only when using it on document.

Activity

  1. Noext commented on Jul 26, 2018

    @Noext

    same issue on ubuntu

    this.db.collection('polls').doc('id').snapshotChanges().subscribe(poll => {})

    poll.payload is not a DocumentChange, so you can't call .doc property to retrieve le document

  2. davideast commented on Aug 17, 2018

    @davideast
    Collaborator

    @Bielik20 @Noext We are changing doc.snapshotChanges() to return a Observable<DocumentSnapshot<T>> in the next release. The type is useless on it because it is always a value update regardless of the type of change.

  3. CheckMater commented on Sep 2, 2018

    @CheckMater

    How can I know which change occurred (added, modified, removed) if the type field is always equal to "value"?

    Thanks.

  4. AnthonyGilliam commented on Sep 22, 2018

    @AnthonyGilliam

    Hi @davideast thanks for all the hard work on this great project, love the way it auto-syncs data. Favor: could one of the contributors update the docs on the doc.snapshotChanges() method? I'm using @angular/fire 5.0.0 and this change is in there, but I have next to no idea how to use this method now.

    THANKS!

  5. rubenCortes commented on May 10, 2019

    @rubenCortes

    The problem persists to the present date. I just met it.

  6. Malspherus commented on May 17, 2019

    @Malspherus

    @davideast what release were you referencing? I couldn't find anything finished or a pull request and the unusable type causes quite dirty code down the line.

  7. mcarriere commented on Jun 1, 2020

    @mcarriere

    Still having this issue to this day

  8. KingDarBoja commented on Jun 4, 2020

    @KingDarBoja
    Contributor

    Having same issue as author, the type on Action type is always returning value no matter what. Maybe we must use snapshotChanges() on a collection-document chain instead?

  9. sur97c commented on Jun 9, 2020

    @sur97c

    I have same issue, is imposible to know what type of changes was performed over one specific document using the snapshotChanges, someone know some workaround to resolve this issue?

  10. jamesdaniels commented on Nov 18, 2020

    @jamesdaniels
    Contributor

    closing in favor of #2108

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions