Streaming Data from Firebase into Dash

Hi

I’m using Firebase (A real time database) in my Dash app. Currently I’m connecting with Pyrebase (A python-Firebase wrapper) and checking for updates using the dash ‘interval’ functionality which works fine.

Ideally though I’d like to take advantage of Firebase’s streaming functionality and just ‘listen’ to updates via the stream handler, which is setup as follows…

def stream_handler(message):
print(message[“event”]) # put
print(message[“path”]) # Key
print(message[“data”]) # {‘title’: ‘Pyrebase’, “body”: “etc…”}

my_stream = db.child(“posts”).stream(stream_handler)

Does anyone have any advice on how to implement this within a dash app?

Thanks

1 Like

Unfortunately, there isn’t anyway to “push” updates from the server to the front-end, so using an Interval is the best way to do this right now.

I’d like to support server “push” (websockets) but it’s a big project - if your organization or company would like to sponsor this feature, please get in touch: https://plot.ly/products/consulting-and-oem/

1 Like

Do you have any thoughts on implementing this? I am also interested in this, since I hope to use Dash as a labview replacement for low-overhead sensor projects I work with. I’ve done a ton of development with websockets and flask (without React) and am willing to take a stab at it over the next few months if someone wants to spitball ideas on implementation…

2 Likes

@chriddyp I also think this will be a really nice feature. HTTP requests are substantially slower than websockets. This will help speed up the data loading procedure specially when it’s designed towards high storage data. I’m fed up with slow runtimes and temporarily relying to client_callbacks in my recent project (which is another hectic). I am also curious about the current ideas on implementation. I have some free time over the next few months, so let me know.

1 Like

Hello @appleplaza,

Have you looked at dash-extensions, they have websockets.