{"id":13719146,"url":"https://github.com/RxSwiftCommunity/FirebaseRxSwiftExtensions","last_synced_at":"2025-05-07T11:31:20.723Z","repository":{"id":35487366,"uuid":"39756632","full_name":"RxSwiftCommunity/FirebaseRxSwiftExtensions","owner":"RxSwiftCommunity","description":"Extension Methods for Firebase and RxSwift","archived":false,"fork":false,"pushed_at":"2016-05-21T23:08:58.000Z","size":38872,"stargazers_count":77,"open_issues_count":2,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-11T18:32:08.551Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RxSwiftCommunity.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-27T05:27:03.000Z","updated_at":"2024-03-04T04:07:30.000Z","dependencies_parsed_at":"2022-09-06T19:22:41.460Z","dependency_job_id":null,"html_url":"https://github.com/RxSwiftCommunity/FirebaseRxSwiftExtensions","commit_stats":null,"previous_names":["mbalex99/firebaserxswiftextensions"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RxSwiftCommunity%2FFirebaseRxSwiftExtensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RxSwiftCommunity%2FFirebaseRxSwiftExtensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RxSwiftCommunity%2FFirebaseRxSwiftExtensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RxSwiftCommunity%2FFirebaseRxSwiftExtensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RxSwiftCommunity","download_url":"https://codeload.github.com/RxSwiftCommunity/FirebaseRxSwiftExtensions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224592472,"owners_count":17337100,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-03T01:00:43.297Z","updated_at":"2024-11-14T08:31:25.662Z","avatar_url":"https://github.com/RxSwiftCommunity.png","language":"Swift","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# FirebaseRxSwiftExtensions\n\n[![CI Status](http://img.shields.io/travis/Maximilian Alexander/FirebaseRxSwiftExtensions.svg?style=flat)](https://travis-ci.org/Maximilian Alexander/FirebaseRxSwiftExtensions)\n[![Version](https://img.shields.io/cocoapods/v/FirebaseRxSwiftExtensions.svg?style=flat)](http://cocoapods.org/pods/FirebaseRxSwiftExtensions)\n[![License](https://img.shields.io/cocoapods/l/FirebaseRxSwiftExtensions.svg?style=flat)](http://cocoapods.org/pods/FirebaseRxSwiftExtensions)\n[![Platform](https://img.shields.io/cocoapods/p/FirebaseRxSwiftExtensions.svg?style=flat)](http://cocoapods.org/pods/FirebaseRxSwiftExtensions)\n\n## WARNING\n\nThis project is for Firebase 2.x. Firebase 2.x will still work with your database but it doesn't have any support for the new packages. I will support this project as long as Firebase supports 2.x. \n\nThis cannot be used Firebase 3.x is not a simple upgrade and currently their podspec is incorrectly configured to be used in any 3rd party project. We expect this to be addressed soon as their projects Firebase UI \u0026 GeoFire will probably need updating. Please follow this issue https://github.com/RxSwiftCommunity/FirebaseRxSwiftExtensions/issues/8 for more updates. \n\nFirebase 3.x library is much larger and complex and will be a seperate project called : RxFirebase (https://github.com/RxSwiftCommunity/RxFirebase)\n\n\n## Usage\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Requirements\n\nThis library is built on Swift 2.2 and needs Xcode 7 or higher to work.\nThis library is build for RxSwift 2.5 or higher. Please take note of the syntax changes when migrating from an\nolder version of Swift to Swift 2 or higher.\n\n## Installation\n\nFirebaseRxSwiftExtensions is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"FirebaseRxSwiftExtensions\"\n```\n\n## Modules Needed\n\nimport Firebase\nimport RxSwift\nimport FirebaseRxSwiftExtensions\n\n### Highly Recommended\n\n## Use DisposeBags\nI highly recommend always having a `disposeBag` available in every controller.\nIt's very important to dispose the subscription or else Firebase may never stop listening when ViewControllers are deallocated\n\nIf you are referencing a weak variable in your `subscribe` or `subscribeNext` blocks, please make sure to use `[unowned self]` to prevent\na retain cycle.\n\nFor example:\n\n```swift\n    var disposeBag = DisposeBag()\n    @IBOutlet weak var nameLabel: UILabel!\n    override func viewDidLoad(animated: bool)\n        // .. stuff\n\n        query.rx_observe(FEventType.ChildAdded)\n            .subscribeNext{ [unowned self] snapshot in\n                self.nameLabel.text = snapshot.value[\"name\"] as! String\n            }\n            .addDisposableTo(disposeBag)\n    }\n```\n\n### Observe a Snapshot\n\nThe `rx_observe(eventType: FEventType)` method observes a Firebase reference or a FQuery for its snapshot.\n\n```swift\n    let query = Firebase(url: \"myUrl\").queryOrderedByChild(\"height\")\n    query.rx_observe(.ChildAdded)\n        .subscribeNext{ (snapshot: FDataSnapshot) in\n            //do something with your snapshot\n        }\n\nTo listen for a snapshot and it's siblingKey. This is useful events like FEventType.ChildMoved and FEventType.ChildChanged\n\n    let query = Firebase(url: \"myUrl\").queryOrderedByChild(\"height\")\n\n    query.rx_observeWithSiblingKey(.ChildRemoved)\n        .subscribeNext{ (tuple: (FDataSnapshot, String) in\n            // The tuple contains the snapshot and the sibling key\n        }\n```\n\nCool hint: You can name parts of your tuple to make things easier\n\n```swift\n    let query = Firebase(url: \"myUrl\").queryOrderedByChild(\"height\")\n\n    query.rx_observeWithSiblingKey(.ChildRemoved)\n        .subscribeNext{ (tuple: (snapshot: FDataSnapshot, siblingKey: String) in\n            // The tuple contains the snapshot and the sibling key\n            print(tuple.snapshot)\n            print(tuple.siblingKey)\n        }\n```\n\n\n### Observe a Snapshot Once\n\nI didn't create an observeSingleEvent rx method. Simply just do a `take(1)` on an FQuery or Firebase reference.\n\n```swift\n    queryOrRef.rx_observe(.ChildAdded).take(1)\n        .subscribeNext{ (snapshot: FDataSnapshot) in\n            //this snapshot is fired once and the listener is disposed of as soon as it fires just once.\n        }\n```\n\n### Set and Update values\n\nThese are relatively straight forward. The operate exactly like their native Firebase equivalents\n\n- `rx_setValues`\n- `rx_updateChildValues`\n\n## Authentication\n\nYou can easily observe your authentication state\n\n```swift\n    let ref = Firebase(url: \"myUrl\")\n    ref.rx_authObservable()\n        .subscribeNext{ authData in\n            if let authData == authData {\n                print(\"You're logged in, authData is not nil\")\n            }else{\n                print(\"You are NOT logged in\")\n            }\n        }\n```\n\nYou can authenticate with respective methods\n\n```swift\n    rx_auth(email: String, password: String) -\u003e Observable\u003cFAuthData\u003e\n    rx_authWithCustomToken(customToken: String) -\u003e Observable\u003cFAuthData\u003e\n    rx_authWithOAuthProvider(provider: String, token: String) -\u003e Observable\u003cFAuthData\u003e\n    rx_authWithOAuthProvider(provider: String, parameters: [NSObject: AnyObject]) -\u003e Observable\u003cFAuthData\u003e\n    rx_authAnonymously() -\u003e Observable\u003cFAuthData\u003e\n    rx_createUser(username: String, password: String) -\u003e Observable\u003c[NSObject: AnyObject]\u003e\n```\n\nMore authentication methods to come!\n\n## Convenience methods\n\nYou can check if a snapshot has a value or not by these two extension methods. They operate on `Observable\u003cFDataSnapshot\u003e`\n\n- `rx_filterWhenNSNull()`\n- `rx_filterWhenNotNSNull()`\n\n## Author\n\nMaximilian Alexander, mbalex99@gmail.com\n\n## License\n\nFirebaseRxSwiftExtensions is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRxSwiftCommunity%2FFirebaseRxSwiftExtensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRxSwiftCommunity%2FFirebaseRxSwiftExtensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRxSwiftCommunity%2FFirebaseRxSwiftExtensions/lists"}