Skip to content

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud Dorgans committed Apr 3, 2018
1 parent 5af912c commit e78e10f
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ Carthage/Build
# `pod install` in .travis.yml
#
# Pods/
/Example/RxFirebase.xcworkspace/xcshareddata
/Example/RxFirebase.xcworkspace
/Example/Pods
2 changes: 1 addition & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use_frameworks!

target 'RxFirebase_Example' do
pod 'RxFirebase/Firestore', :path => '../'
pod 'RxFirebase/Core', :path => '../'
pod 'RxFirebase/RemoteConfig', :path => '../'

target 'RxFirebase_Tests' do
inherit! :search_paths
Expand Down
28 changes: 21 additions & 7 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ PODS:
- 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)
Expand All @@ -20,6 +23,13 @@ PODS:
- 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)
Expand Down Expand Up @@ -51,30 +61,34 @@ PODS:
- Protobuf (3.5.0)
- RxCocoa (4.1.2):
- RxSwift (~> 4.0)
- RxFirebase/Core (0.1.0):
- FirebaseCore
- RxFirebase/Firestore (0.1.0):
- FirebaseCore (~> 4)
- FirebaseFirestore (~> 0)
- RxCocoa (~> 4)
- RxSwift (~> 4)
- RxFirebase/Firestore (0.1.0):
- FirebaseFirestore
- RxFirebase/RemoteConfig (0.1.0):
- FirebaseCore (~> 4)
- FirebaseRemoteConfig (~> 2)
- RxCocoa (~> 4)
- RxSwift (~> 4)
- RxSwift (4.1.2)

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

EXTERNAL SOURCES:
RxFirebase:
:path: ../

SPEC CHECKSUMS:
BoringSSL: 32764dbaf5f5888cf51fbaa172a010126b41bcd4
FirebaseABTesting: d07d0ee833b842d5153549e4c7e2e2cb1c23a3f9
FirebaseAnalytics: 3dfae28d4a5e06f86c4fae830efc2ad3fadb19bc
FirebaseCore: b981f47e5254cbcfdeb483355300d743f6fcab2c
FirebaseFirestore: 796df79c29cf8ecf806564f4d347665bdafa6ef0
FirebaseInstanceID: 8d20d890d65c917f9f7d9950b6e10a760ad34321
FirebaseRemoteConfig: df64ce784a45e9b9d4988030a59da6baede8bdb0
GoogleToolboxForMac: 2501e2ad72a52eb3dfe7bd9aee7dad11b858bd20
gRPC: f54f0e6d603052b4562447da442ce2ff30bcdacc
gRPC-Core: a030b1678ded49c88ec5ba7c90ee8ee5f47ec6e1
Expand All @@ -84,9 +98,9 @@ SPEC CHECKSUMS:
nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
Protobuf: 8a9838fba8dae3389230e1b7f8c104aa32389c03
RxCocoa: d88ba0f1f6abf040011a9eb4b539324fc426843a
RxFirebase: 3bc3bbc1e7599c2f3aaedde9debde5537c1d9c1a
RxFirebase: fa49a55c75f8d501b69cb6bde368449c0b27ebf7
RxSwift: e49536837d9901277638493ea537394d4b55f570

PODFILE CHECKSUM: bcea1d407c8677e9d6cda7c19588a1bc242c4f14
PODFILE CHECKSUM: a5b068a211fcbb54a7281d0b2f5acde20991d4e1

COCOAPODS: 1.4.0
10 changes: 0 additions & 10 deletions Example/RxFirebase.xcworkspace/contents.xcworkspacedata

This file was deleted.

9 changes: 3 additions & 6 deletions Example/RxFirebase/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@
//

import UIKit
import RxFirebase
import FirebaseRemoteConfig

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

}

29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ it, simply add the following line to your Podfile:

```ruby
pod 'RxFirebase/Firestore'
pod 'RxFirebase/RemoteConfig'
```

## Usage
Expand Down Expand Up @@ -76,7 +77,7 @@ db.collection("cities")
// https://firebase.google.com/docs/firestore/manage-data/add-data
```

Get a document
Get a document:
```swift
let db = Firestore.firestore()

Expand All @@ -97,7 +98,7 @@ db.collection("cities")
// https://firebase.google.com/docs/firestore/query-data/get-data
```

Get Realtime Updates
Get Realtime Updates:
```swift
let db = Firestore.firestore()

Expand Down Expand Up @@ -135,7 +136,7 @@ db.collection("cities")
// https://firebase.google.com/docs/firestore/query-data/listen
```

Batched writes
Batched writes:
```swift
let db = Firestore.firestore()

Expand All @@ -158,7 +159,7 @@ batch.rx
// https://firebase.google.com/docs/firestore/manage-data/transactions
```

Transactions
Transactions:
```swift
let db = Firestore.firestore()
let sfReference = db.collection("cities").document("SF")
Expand Down Expand Up @@ -195,6 +196,26 @@ db.rx.runTransaction { transaction, errorPointer in
// https://firebase.google.com/docs/firestore/manage-data/transactions
```

### RemoteConfig

Fetch:
```swift
// TimeInterval is set to expirationDuration here, indicating the next fetch request will use
// data fetched from the Remote Config service, rather than cached parameter values, if cached
// parameter values are more than expirationDuration seconds old. See Best Practices in the
// README for more information.
RemoteConfig.remoteConfig()
.rx
.fetch(withExpirationDuration: TimeInterval(expirationDuration), activateFetched: true)
.subscribe(onNext: { status in
print("Config fetched! with success:\(status == .success)")
}, onError: { error in
print("Error: \(error)")
}).disposed(by: disposeBag)

// https://firebase.google.com/docs/remote-config/ios
```

## Author

Arnaud Dorgans, [email protected]
Expand Down
14 changes: 6 additions & 8 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.0'
s.version = '0.1.1'
s.summary = 'RxSwift extensions for Firebase.'

# This description is used to generate tags and improve search results.
Expand Down Expand Up @@ -36,16 +36,14 @@ s.swift_version = '4.1'
s.dependency 'RxCocoa', '~> 4'
s.dependency 'FirebaseCore', '~> 4'

#s.subspec 'Core' do |core|
#core.source_files = 'RxFirebase/Classes/Core/**/*'
#end
#s.subspec 'Database' do |database|
#database.source_files = 'RxFirebase/Classes/Database/**/*'
#database.dependency 'FirebaseDatabase', '~> 4'
#end
s.subspec 'Firestore' do |firestore|
firestore.source_files = 'RxFirebase/Classes/Firestore/**/*'
firestore.dependency 'FirebaseFirestore', '~> 0'
end
s.subspec 'RemoteConfig' do |remote|
remote.source_files = 'RxFirebase/Classes/RemoteConfig/**/*'
remote.dependency 'FirebaseRemoteConfig', '~> 2'
end


end
55 changes: 55 additions & 0 deletions RxFirebase/Classes/RemoteConfig/RemoteConfig+Rx.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// RemoteConfig+Rx.swift
// RxFirebase
//
// Created by Arnaud Dorgans on 03/04/2018.
//

import UIKit
import RxSwift
import FirebaseRemoteConfig

extension Reactive where Base: RemoteConfig {

/// Fetches Remote Config data with a callback. Call activateFetched to make fetched data available
/// to your app.
/// @param completionHandler Fetch operation callback.
public func fetch(activateFetched: Bool = false) -> Observable<RemoteConfigFetchStatus> {
return Observable<RemoteConfigFetchStatus>.create { observer in
self.base.fetch { status, error in
guard let error = error else {
if activateFetched, status == .success {
self.base.activateFetched()
}
observer.onNext(status)
observer.onCompleted()
return
}
observer.onError(error)
}
return Disposables.create()
}
}

/// Fetches Remote Config data and sets a duration that specifies how long config data lasts.
/// Call activateFetched to make fetched data available to your app.
/// @param expirationDuration Duration that defines how long fetched config data is available, in
/// seconds. When the config data expires, a new fetch is required.
/// @param completionHandler Fetch operation callback.
public func fetch(withExpirationDuration duration: TimeInterval, activateFetched: Bool = false) -> Observable<RemoteConfigFetchStatus> {
return Observable<RemoteConfigFetchStatus>.create { observer in
self.base.fetch(withExpirationDuration: duration) { status, error in
guard let error = error else {
if activateFetched, status == .success {
self.base.activateFetched()
}
observer.onNext(status)
observer.onCompleted()
return
}
observer.onError(error)
}
return Disposables.create()
}
}
}

0 comments on commit e78e10f

Please sign in to comment.