Skip to content

Commit

Permalink
Merge branch 'feature/database' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	Podfile.lock
#	Sources/Firestore/FIRDocumentReference+Rx.swift
#	Sources/Firestore/FIRQuery+Rx.swift
  • Loading branch information
Arnaud Dorgans committed May 16, 2018
2 parents 0e69c81 + c250eef commit fb282b4
Show file tree
Hide file tree
Showing 10 changed files with 594 additions and 87 deletions.
2 changes: 0 additions & 2 deletions Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
//

import UIKit
import RxFirebase
import FirebaseRemoteConfig

class ViewController: UIViewController {

Expand Down
1 change: 1 addition & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use_frameworks!
target 'RxFirebase_Example' do
pod 'RxFirebase/Firestore', :path => './'
pod 'RxFirebase/RemoteConfig', :path => './'
pod 'RxFirebase/Database', :path => './'

target 'RxFirebase_Tests' do
inherit! :search_paths
Expand Down
143 changes: 79 additions & 64 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,57 +1,65 @@
PODS:
- BoringSSL (10.0):
- BoringSSL/Implementation (= 10.0)
- BoringSSL/Interface (= 10.0)
- BoringSSL/Implementation (10.0):
- BoringSSL/Interface (= 10.0)
- BoringSSL/Interface (10.0)
- FirebaseABTesting (1.0.0):
- FirebaseCore (~> 4.0)
- Protobuf (~> 3.1)
- FirebaseAnalytics (4.1.0):
- FirebaseCore (~> 4.0)
- FirebaseInstanceID (~> 2.0)
- BoringSSL (10.0.2):
- BoringSSL/Implementation (= 10.0.2)
- BoringSSL/Interface (= 10.0.2)
- BoringSSL/Implementation (10.0.2):
- BoringSSL/Interface (= 10.0.2)
- BoringSSL/Interface (10.0.2)
- FirebaseABTesting (2.0.0):
- FirebaseCore (~> 5.0)
- Protobuf (~> 3.5)
- FirebaseAnalytics (5.0.0):
- FirebaseCore (~> 5.0)
- FirebaseInstanceID (~> 3.0)
- "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
- nanopb (~> 0.3)
- FirebaseCore (4.0.18):
- FirebaseCore (5.0.1):
- "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
- FirebaseFirestore (0.10.4):
- FirebaseAnalytics (~> 4.1)
- FirebaseCore (~> 4.0)
- FirebaseDatabase (5.0.0):
- FirebaseCore (~> 5.0)
- leveldb-library (~> 1.18)
- FirebaseFirestore (0.12.1):
- FirebaseCore (~> 5.0)
- FirebaseFirestore/abseil-cpp (= 0.12.1)
- gRPC-ProtoRPC (~> 1.0)
- leveldb-library (~> 1.18)
- Protobuf (~> 3.1)
- FirebaseFirestore/abseil-cpp (0.12.1):
- FirebaseCore (~> 5.0)
- gRPC-ProtoRPC (~> 1.0)
- leveldb-library (~> 1.18)
- Protobuf (~> 3.5)
- FirebaseInstanceID (2.0.10):
- FirebaseCore (~> 4.0)
- FirebaseRemoteConfig (2.1.2):
- FirebaseABTesting (~> 1.0)
- FirebaseAnalytics (~> 4.0)
- FirebaseCore (~> 4.0)
- FirebaseInstanceID (~> 2.0)
- "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
- Protobuf (~> 3.1)
- GoogleToolboxForMac/Defines (2.1.3)
- "GoogleToolboxForMac/NSData+zlib (2.1.3)":
- GoogleToolboxForMac/Defines (= 2.1.3)
- gRPC (1.10.0):
- gRPC-RxLibrary (= 1.10.0)
- gRPC/Main (= 1.10.0)
- gRPC-Core (1.10.0):
- gRPC-Core/Implementation (= 1.10.0)
- gRPC-Core/Interface (= 1.10.0)
- gRPC-Core/Implementation (1.10.0):
- FirebaseInstanceID (3.0.0):
- FirebaseCore (~> 5.0)
- FirebaseRemoteConfig (3.0.0):
- FirebaseABTesting (~> 2.0)
- FirebaseAnalytics (~> 5.0)
- FirebaseCore (~> 5.0)
- FirebaseInstanceID (~> 3.0)
- "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
- Protobuf (~> 3.5)
- GoogleToolboxForMac/Defines (2.1.4)
- "GoogleToolboxForMac/NSData+zlib (2.1.4)":
- GoogleToolboxForMac/Defines (= 2.1.4)
- gRPC (1.11.0):
- gRPC-RxLibrary (= 1.11.0)
- gRPC/Main (= 1.11.0)
- gRPC-Core (1.11.0):
- gRPC-Core/Implementation (= 1.11.0)
- gRPC-Core/Interface (= 1.11.0)
- gRPC-Core/Implementation (1.11.0):
- BoringSSL (~> 10.0)
- gRPC-Core/Interface (= 1.10.0)
- gRPC-Core/Interface (= 1.11.0)
- nanopb (~> 0.3)
- gRPC-Core/Interface (1.10.0)
- gRPC-ProtoRPC (1.10.0):
- gRPC (= 1.10.0)
- gRPC-RxLibrary (= 1.10.0)
- gRPC-Core/Interface (1.11.0)
- gRPC-ProtoRPC (1.11.0):
- gRPC (= 1.11.0)
- gRPC-RxLibrary (= 1.11.0)
- Protobuf (~> 3.0)
- gRPC-RxLibrary (1.10.0)
- gRPC/Main (1.10.0):
- gRPC-Core (= 1.10.0)
- gRPC-RxLibrary (= 1.10.0)
- gRPC-RxLibrary (1.11.0)
- gRPC/Main (1.11.0):
- gRPC-Core (= 1.11.0)
- gRPC-RxLibrary (= 1.11.0)
- leveldb-library (1.20)
- nanopb (0.3.8):
- nanopb/decode (= 0.3.8)
Expand All @@ -61,26 +69,32 @@ PODS:
- Protobuf (3.5.0)
- RxCocoa (4.1.2):
- RxSwift (~> 4.0)
- RxFirebase/Firestore (0.1.1):
- FirebaseFirestore (~> 0)
- RxFirebase/Database (0.2):
- FirebaseDatabase (~> 5)
- RxCocoa (~> 4)
- RxSwift (~> 4)
- RxFirebase/Firestore (0.2):
- FirebaseFirestore (~> 0.12)
- RxCocoa (~> 4)
- RxSwift (~> 4)
- RxFirebase/RemoteConfig (0.1.1):
- FirebaseRemoteConfig (~> 2)
- RxFirebase/RemoteConfig (0.2):
- FirebaseRemoteConfig (~> 3)
- RxCocoa (~> 4)
- RxSwift (~> 4)
- RxSwift (4.1.2)

DEPENDENCIES:
- RxFirebase/Database (from `./`)
- RxFirebase/Firestore (from `./`)
- RxFirebase/RemoteConfig (from `./`)

SPEC REPOS:
https://github.com/CocoaPods/Specs.git:
https://github.com/cocoapods/specs.git:
- BoringSSL
- FirebaseABTesting
- FirebaseAnalytics
- FirebaseCore
- FirebaseDatabase
- FirebaseFirestore
- FirebaseInstanceID
- FirebaseRemoteConfig
Expand All @@ -100,25 +114,26 @@ EXTERNAL SOURCES:
:path: "./"

SPEC CHECKSUMS:
BoringSSL: 32764dbaf5f5888cf51fbaa172a010126b41bcd4
FirebaseABTesting: d07d0ee833b842d5153549e4c7e2e2cb1c23a3f9
FirebaseAnalytics: 3dfae28d4a5e06f86c4fae830efc2ad3fadb19bc
FirebaseCore: b981f47e5254cbcfdeb483355300d743f6fcab2c
FirebaseFirestore: 796df79c29cf8ecf806564f4d347665bdafa6ef0
FirebaseInstanceID: 8d20d890d65c917f9f7d9950b6e10a760ad34321
FirebaseRemoteConfig: df64ce784a45e9b9d4988030a59da6baede8bdb0
GoogleToolboxForMac: 2501e2ad72a52eb3dfe7bd9aee7dad11b858bd20
gRPC: f54f0e6d603052b4562447da442ce2ff30bcdacc
gRPC-Core: a030b1678ded49c88ec5ba7c90ee8ee5f47ec6e1
gRPC-ProtoRPC: 22712b23eb1bda656a59715fa5c1da0ea1493ea4
gRPC-RxLibrary: a41a4652d220f230ba1c0491a94ce2ee04c6180a
BoringSSL: 60dd24df4af296bf41d78e5841dbb95d75f88c0d
FirebaseABTesting: 1f50b8d50f5e3469eea54e7463a7b7fe221d1f5e
FirebaseAnalytics: 19812b49fa5f283dd6b23edf8a14b5d477029ab8
FirebaseCore: cafc814b2d84fc8733f09e653041cc2165332ad7
FirebaseDatabase: 697eb53e5b4fe7cd4fa8756c1f82a9fca011345f
FirebaseFirestore: f686b8e83f3cf8bbc37db6e98e01029a14f01f55
FirebaseInstanceID: 83e0040351565df711a5db3d8ebe5ea21aca998a
FirebaseRemoteConfig: 3c57e4644bd6976b671ae0b725cd709f198bd1f5
GoogleToolboxForMac: 91c824d21e85b31c2aae9bb011c5027c9b4e738f
gRPC: 70703dc9ba31c72341fc7f37745cc1c379edee96
gRPC-Core: 164639cd8ae18ca8b65477fafb2efbaecf4f181a
gRPC-ProtoRPC: bb5fddf3424aa4fad74d76736578a79fe40e244e
gRPC-RxLibrary: 26d53d1b1f306befd4ad4e15bd6de27839a82481
leveldb-library: 08cba283675b7ed2d99629a4bc5fd052cd2bb6a5
nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
Protobuf: 8a9838fba8dae3389230e1b7f8c104aa32389c03
RxCocoa: d88ba0f1f6abf040011a9eb4b539324fc426843a
RxFirebase: b07a6224e403b0de0768263995d07b8e9fd26af3
RxFirebase: 564de37ff7429fb88313635d8a4b16c656bd9bbd
RxSwift: e49536837d9901277638493ea537394d4b55f570

PODFILE CHECKSUM: 8f90624e0becef45dcf3aec26ef7ee92a0f5beef
PODFILE CHECKSUM: fde8e8f30c4a2721a77fa8212056b41e090fe118

COCOAPODS: 1.5.0
COCOAPODS: 1.5.2
95 changes: 91 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
[![License](https://img.shields.io/cocoapods/l/RxFirebase.svg?style=flat)](http://cocoapods.org/pods/RxFirebase)
[![Platform](https://img.shields.io/cocoapods/p/RxFirebase.svg?style=flat)](http://cocoapods.org/pods/RxFirebase)

## Example

To run the example project, clone the repo, and run `pod install` from the Example directory first.

## Requirements

Xcode 9.0
Expand All @@ -23,6 +19,7 @@ it, simply add the following line to your Podfile:
```ruby
pod 'RxFirebase/Firestore'
pod 'RxFirebase/RemoteConfig'
pod 'RxFirebase/Database'
```

## Usage
Expand All @@ -31,6 +28,96 @@ pod 'RxFirebase/RemoteConfig'
import RxFirebase
```

- [Database](#database)
- [Firestore](#firestore)
- [RemoteConfig](#remoteconfig)

### Database

Basic write operation:
```swift
let ref = Database.database().reference()

ref.child("users")
.child("1")
.rx
.setValue(["username": "Arnonymous"])
.subscribe(onNext: { _ in
print("Document successfully updated")
}).disposed(by: disposeBag)

// https://firebase.google.com/docs/database/ios/read-and-write#basic_write
```

Listen for value events:
```swift
let ref = Database.database().reference()

ref.child("users")
.child("1")
.rx
.observeEvent(.value)
.subscribe(onNext: { snapshot in
print("Value:\(snapshot.value)")
}).disposed(by: disposeBag)

// https://firebase.google.com/docs/database/ios/read-and-write#listen_for_value_events
```

Read data once:
```swift
let ref = Database.database().reference()

ref.child("users")
.child("1")
.rx
.observeSingleEvent(.value)
.subscribe(onNext: { snapshot in
print("Value:\(snapshot.value)")
}).disposed(by: disposeBag)

// https://firebase.google.com/docs/database/ios/read-and-write#read_data_once
```

Update specific fields:
```swift
let ref = Database.database().reference()

let childUpdates = ["/posts/\(key)": post,
"/user-posts/\(userID)/\(key)/": post]
ref.rx.updateChildValues(childUpdates)
.subscribe(onNext: { _ in
// Success
}).disposed(by: disposeBag)

// https://firebase.google.com/docs/database/ios/read-and-write#update_specific_fields
```

Delete data:
```swift
let ref = Database.database().reference()

ref.rx.removeValue()
.subscribe(onNext: { _ in
// Success
}).disposed(by: disposeBag)

// https://firebase.google.com/docs/database/ios/read-and-write#delete_data
```

Save data as transactions
```swift
let ref = Database.database().reference()

ref.rx.runTransactionBlock { currentData in
// TransactionResult
}.subscribe(onNext: { _ in
// Success
}).disposed(by: disposeBag)

// https://firebase.google.com/docs/database/ios/read-and-write#save_data_as_transactions
```

### Firestore

Setting data:
Expand Down
12 changes: 8 additions & 4 deletions RxFirebase.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'RxFirebase'
s.version = '0.1.1'
s.version = '0.2'
s.summary = 'RxSwift extensions for Firebase.'

# This description is used to generate tags and improve search results.
Expand All @@ -19,7 +19,7 @@ Pod::Spec.new do |s|

s.description = <<-DESC
RxSwift extensions for Firebase.
Including for now Firestore, RemoteConfig
Including for now Database, Firestore, RemoteConfig
DESC

s.homepage = 'https://github.com/RxSwiftCommunity/RxFirebase'
Expand All @@ -38,10 +38,14 @@ Pod::Spec.new do |s|

s.subspec 'Firestore' do |firestore|
firestore.source_files = 'Sources/Firestore/**/*'
firestore.dependency 'FirebaseFirestore', '~> 0'
firestore.dependency 'FirebaseFirestore', '~> 0.12'
end
s.subspec 'RemoteConfig' do |remote|
remote.source_files = 'Sources/RemoteConfig/**/*'
remote.dependency 'FirebaseRemoteConfig', '~> 2'
remote.dependency 'FirebaseRemoteConfig', '~> 3'
end
s.subspec 'Database' do |database|
database.source_files = 'Sources/Database/**/*'
database.dependency 'FirebaseDatabase', '~> 5'
end
end
Loading

0 comments on commit fb282b4

Please sign in to comment.