{"id":18924656,"url":"https://github.com/dash-os/firebase-listener","last_synced_at":"2026-04-27T11:31:12.482Z","repository":{"id":71821414,"uuid":"93086794","full_name":"Dash-OS/firebase-listener","owner":"Dash-OS","description":"🔥 Setup \u0026 Manage Your Firebase Listeners 🔥","archived":false,"fork":false,"pushed_at":"2017-06-01T20:13:59.000Z","size":16,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-24T23:41:07.417Z","etag":null,"topics":["firebase","firebase-database"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dash-OS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-06-01T18:19:23.000Z","updated_at":"2020-02-14T08:17:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"fabb64ca-2ae7-4dd9-984f-bdadd035a39e","html_url":"https://github.com/Dash-OS/firebase-listener","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Dash-OS/firebase-listener","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dash-OS%2Ffirebase-listener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dash-OS%2Ffirebase-listener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dash-OS%2Ffirebase-listener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dash-OS%2Ffirebase-listener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dash-OS","download_url":"https://codeload.github.com/Dash-OS/firebase-listener/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dash-OS%2Ffirebase-listener/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32335295,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["firebase","firebase-database"],"created_at":"2024-11-08T11:07:39.754Z","updated_at":"2026-04-27T11:31:12.476Z","avatar_url":"https://github.com/Dash-OS.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# firebase-listener\n\nA Utility to assist in the setup and management of your Firebase Refs.  Assists with \nmanaging various paths of your database and their events.  Assists with common patterns \nto provide a refreshing developer experience.\n\nWe utility [seamless-immutable](https://github.com/rtfeldman/seamless-immutable) to manage \nand detect changes to your refs events so that we can notify you.\n\nUpdates are provided using a [PromiseQueue](https://github.com/Dash-OS/promise-queue-observable) \nwhich allows for simple integration with many 3rd party libraries.\n\n\u003e This was designed to make using Firebase with [redux-saga](https://github.com/redux-saga/redux-saga) \n\u003e a better experience during our development.\n\n\u003e **Important:** This is NOT stable at this time.\n\n### What About Writing to Firebase?\n\nWe use Firebase as a top-down approach - similar to [redux](http://redux.js.org/) \nin many ways.  Our app never directly modifies the firebase.  Instead, we dispatch \nactions to [AWS Lambda](https://aws.amazon.com/lambda/) which then \"reduces\" the event \nand updates our database(s) accordingly.  \n\nYou can still use the ref to update directly if needed.  Since switching to the model \ndescribed above, things have become much more streamlined and easier to handle.\n\n### Saga Example \n\nBelow is a simple example of a saga from [redux-saga](https://github.com/redux-saga/redux-saga) \nusing this package to listen to a path.  \n\nIn this case we are registering the firebase events \n[child_added](https://firebase.google.com/docs/database/admin/retrieve-data#child-added), \n[child_removed](https://firebase.google.com/docs/database/admin/retrieve-data#child-removed), \n[child_changed](https://firebase.google.com/docs/database/admin/retrieve-data#child-changed) \n-- however, we use the rehydrate configuration to also register a \n[once](https://firebase.google.com/docs/database/admin/retrieve-data#section-reading-once) \nthat will update our listener with the entire contents first.  This prevents \nthe listener from receiving child_added events for every child in the path.\n\n```js\nimport { createFirebaseListener } from 'firebase-listener'\n\nfunction* handleFirebaseReady(ref) {\n  let listener\n  try {\n    listener = createFirebaseListener(ref, {\n      // automatically registers value listener, gets the data, rehydrates with \n      // the entire contents, then removes it. this helps so your UI doesn't receive \n      // tons of child_added events needlessly.\n      rehydrate: true,\n      // turn on detailed logs\n      log: 'detailed',\n    }).events('child_added', 'child_removed', 'child_changed').listen()\n\n    while(true) {\n      // next gets the promise that will resolve with the next event that occurs.\n      const event = yield call([ this.state.listener, this.state.listener.next ])\n      yield fork([this, handleFirebaseEvent], event)\n    }\n  } catch (e) {\n    // handle error\n  } finally {\n    // cancel the listener? once cancelled, the listener will no longer allow \n    // any calls to next()\n    listener.cancel()\n  }\n}\n```\n\n### Batched Paths\n\nIf you setup many listeners on a single path throughout your app, this module will only \nend up registering a single listener. At this time it does not allow different parts of \nthe app to setup different events for a given listener.  \n\n\u003e Setting up a listener on a path that was registered elsewhere includes the listener that \n\u003e was already created. \n\n### Logging Events\n\nOne of the things that has always been an issue is logging the various events \nthat occur with the firebase.  We wanted a way to really introspect our listeners \nand events.  \n\nLogging is enabled by adding the `log` parameter when setting up your listener.  It \naccepts the values of `true`, `false` or `'detailed'`.  \n\nWhen `'detailed'` is specified, extra information will be added to each log.  At this \ntime if the log includes a `snapshot` value (events) then it will include the number of \nchildren.  It will also include the events currently registered on the given listener.\n\n##### General Events are Orange\n\n![Firebase Listener Logging](http://i.imgur.com/w5Mfgrp.png)\n\n##### Change Events are Green\n\n![Firebase Rehydrate Event](http://i.imgur.com/g4iXsQl.png)\n\n##### Other Events / Logs are Black\n\n![Firebase Event](http://i.imgur.com/V1aEHOo.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdash-os%2Ffirebase-listener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdash-os%2Ffirebase-listener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdash-os%2Ffirebase-listener/lists"}