Skip to content

Additional Event Firing Fix #1

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
wants to merge 1 commit into from
Closed

Additional Event Firing Fix #1

wants to merge 1 commit into from

Conversation

the-c0d3r
Copy link

@the-c0d3r the-c0d3r commented Jul 13, 2018

I tested the code and it seem like the event streaming is fired as soon as you start the stream on a reference which already have data in the database. Therefore I modified the code to check for the last_value and only fire the event if the value is changed. I modified this to fit my needs, maybe somebody will find this useful as well. Thanks for your commit adding the SSE client.


Original comment from this discussion

I tried your fork repo, somehow it fires off an event as soon as I set the stream() and the callback function is called immediately. But the intended listening event is triggered every time when the data is changed in the database side.

>>> ref.stream(callbackfunc)
<firebase_admin.db.Stream object at 0x10c9b7ef0>
>>> {'event': 'put', 'data': True, 'path': '/'}
>>> # The event above is fired off automatically on stream without modification on db

>>> # these 3 events below are fired off by the changes in the db. 
>>> {'event': 'put', 'data': 'true', 'path': '/'}
>>> {'event': 'put', 'data': 'false', 'path': '/'}
>>> {'event': 'put', 'data': 'true', 'path': '/'}

>>> self.db.reference("/users/dev1/successful").stream(callbackfunc)
<firebase_admin.db.Stream object at 0x10ef897f0>
>>> {'event': 'put', 'data': True, 'path': '/'}
>>> # The event above is fired off automatically on stream without modification on db

Is it possible to fix this unexpected behavior? I would like to help fix it, but I have no idea where to start looking and I have never worked with SSE before. If anyone can point me in correct direction, please do.

I tested the code and it seem like the event streaming is fired as soon as you start the stream on a reference which already have data in the database. Therefore I modified the code to check for the `last_value` and only fire the event if the value is changed. I modified this to fit my needs, maybe somebody will find this useful as well. Thanks for your commit adding the SSE client.
@the-c0d3r
Copy link
Author

Since this feature has been merged into Firebase, I will be closing this.

@the-c0d3r the-c0d3r closed this Aug 15, 2018
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

Successfully merging this pull request may close these issues.

1 participant