Skip to content

Multiple events fired on a subscription when insert element on a list #2116

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

Closed
Hanzofm opened this issue Jun 20, 2019 · 1 comment
Closed

Comments

@Hanzofm
Copy link

Hanzofm commented Jun 20, 2019

Hi,

I have this structure RealTime structure

+Conversations
    -Conversation1
        -Messages
           -message1
           -message2

Initially I subscribe to the message changes with:

this.mylocalconversations.push({
     id,
     type,
     subscription: return 
      this.angularfire.object(Conversations/Conversation1/Messages);
       .snapshotChanges()
        .subscribe((conversation) => {
         console.log('new info')
       }),
   });

Then, i would insert new message with:

this.angularfire.list(Conversations/Conversation1/Messages).push(msg)

The result of this is:

new info
new info

Why the subcribe event fires twice?

Thanks

@jamesdaniels
Copy link
Member

That would be your cache firing first and the server value next; I'm working on APIs to allow additional fidelity here. See #2012

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