Skip to content

Commit

Permalink
Support for Firebase 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
1amageek committed May 18, 2017
1 parent 59d4bd2 commit dcb57ea
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 82 deletions.
46 changes: 24 additions & 22 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
PODS:
- Firebase/Core (3.15.0):
- FirebaseAnalytics (= 3.7.0)
- FirebaseCore (= 3.5.2)
- Firebase/Database (3.15.0):
- Firebase/Core (4.0.0):
- FirebaseAnalytics (= 4.0.0)
- FirebaseCore (= 4.0.0)
- Firebase/Database (4.0.0):
- Firebase/Core
- FirebaseDatabase (= 3.1.2)
- Firebase/Storage (3.15.0):
- FirebaseDatabase (= 4.0.0)
- Firebase/Storage (4.0.0):
- Firebase/Core
- FirebaseStorage (= 1.1.0)
- FirebaseAnalytics (3.7.0):
- FirebaseCore (~> 3.5)
- FirebaseInstanceID (~> 1.0)
- FirebaseStorage (= 2.0.0)
- FirebaseAnalytics (4.0.0):
- FirebaseCore (~> 4.0)
- FirebaseInstanceID (~> 2.0)
- GoogleToolboxForMac/NSData+zlib (~> 2.1)
- FirebaseCore (3.5.2):
- FirebaseCore (4.0.0):
- GoogleToolboxForMac/NSData+zlib (~> 2.1)
- FirebaseDatabase (3.1.2):
- FirebaseAnalytics (~> 3.7)
- FirebaseInstanceID (1.0.9)
- FirebaseStorage (1.1.0):
- FirebaseAnalytics (~> 3.7)
- FirebaseDatabase (4.0.0):
- FirebaseAnalytics (~> 4.0)
- FirebaseInstanceID (2.0.0):
- FirebaseCore (~> 4.0)
- FirebaseStorage (2.0.0):
- FirebaseAnalytics (~> 4.0)
- FirebaseCore (~> 4.0)
- GTMSessionFetcher/Core (~> 1.1)
- GoogleToolboxForMac/Defines (2.1.1)
- GoogleToolboxForMac/NSData+zlib (2.1.1):
Expand All @@ -30,12 +32,12 @@ DEPENDENCIES:
- Firebase/Storage

SPEC CHECKSUMS:
Firebase: 2b1cdfba1cda8589f32904a697cc753322bff9d8
FirebaseAnalytics: 0d1b7d81d5021155be37702a94ba1ec16d45365d
FirebaseCore: a024587e43778508700af8c6b1209f7c4516ba02
FirebaseDatabase: 05c96d7b43a7368dc91c07791adb49683e1738d1
FirebaseInstanceID: 2d0518b1378fe9d685ef40cbdd63d2fdc1125339
FirebaseStorage: a5c55b23741a49a72af8f30f95b3bb5ddbeda12d
Firebase: 284eea779b73fdff309791817da7c68bff8dd572
FirebaseAnalytics: 6f08e746f7d66f5452931bc2e822b5df9c66b64a
FirebaseCore: 85ad466044c2f013cdb167f85d426d15b128114a
FirebaseDatabase: d829b3a8c3e2ac7a16773c5df226966b0805dfc2
FirebaseInstanceID: 9fbf536668f4d3f0880e7438456dabd1376e294b
FirebaseStorage: 8110a1ed2034c8fbfd83890d2acc9cdbbd99afec
GoogleToolboxForMac: 8e329f1b599f2512c6b10676d45736bcc2cbbeb0
GTMSessionFetcher: 5c046c76a1f859bc9c187e918f18e4fc7bb57b5e

Expand Down
4 changes: 2 additions & 2 deletions SaladBar/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FIRApp.configure()
FIRDatabase.database().persistenceEnabled = false
FirebaseApp.configure()
Database.database().isPersistenceEnabled = false
return true
}

Expand Down
6 changes: 3 additions & 3 deletions SaladBar/FileTestViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Firebase

class FileTestViewController: UIViewController {

var task: FIRStorageUploadTask? {
var task: StorageUploadTask? {
didSet {
self.pause = task?.observe(.pause, handler: { (snapshot) in
print(snapshot)
Expand Down Expand Up @@ -50,9 +50,9 @@ class FileTestViewController: UIViewController {
.appendingPathExtension("jpg")

try! data.write(to: tmpURL)
let ref: FIRStorageReference = FIRStorage.storage().reference().child("test")
let ref: StorageReference = Storage.storage().reference().child("test")

self.task = ref.putFile(tmpURL, metadata: nil) { (metadata, error) in
self.task = ref.putFile(from: tmpURL, metadata: nil) { (metadata, error) in

if let error: Error = error as Error? {
print(error)
Expand Down
2 changes: 1 addition & 1 deletion SaladBar/SaladaFileTestViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SaladaFileTestViewController: UIViewController {
let item: Item = Item()
item.file = file
item.index = 0
let task: FIRStorageUploadTask = item.save { (ref, error) in
let task: StorageUploadTask = item.save { (ref, error) in
if let error = error {
print(error)
return
Expand Down
2 changes: 1 addition & 1 deletion SaladBar/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour
self.view.addSubview(tableView)
}

var dbRef: FIRDatabaseReference!
var dbRef: DatabaseReference!

override func viewDidLoad() {
super.viewDidLoad()
Expand Down
2 changes: 1 addition & 1 deletion Salada.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Salada"
s.version = "1.1"
s.version = "2.0"
s.summary = "Salada is OR Mapper for Firebase."
s.homepage = "https://github.com/1amageek/Salada"
s.license = { :type => "BSD" }
Expand Down
20 changes: 10 additions & 10 deletions Salada/Referenceable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ import FirebaseStorage
Protocol that holds a reference Firebase
*/
public protocol Referenceable: NSObjectProtocol {
static var database: FIRDatabaseReference { get }
static var databaseRef: FIRDatabaseReference { get }
static var storage: FIRStorageReference { get }
static var storageRef: FIRStorageReference { get }
static var database: DatabaseReference { get }
static var databaseRef: DatabaseReference { get }
static var storage: StorageReference { get }
static var storageRef: StorageReference { get }
static var _path: String { get }

var id: String { get }
var snapshot: FIRDataSnapshot? { get }
var snapshot: DataSnapshot? { get }
var createdAt: Date { get }
var value: [AnyHashable: Any] { get }
var ignore: [String] { get }

init?(snapshot: FIRDataSnapshot)
init?(snapshot: DataSnapshot)
}

public extension Referenceable {
static var database: FIRDatabaseReference { return FIRDatabase.database().reference() }
static var databaseRef: FIRDatabaseReference { return self.database.child(self._path) }
static var storage: FIRStorageReference { return FIRStorage.storage().reference() }
static var storageRef: FIRStorageReference { return self.storage.child(self._path) }
static var database: DatabaseReference { return Database.database().reference() }
static var databaseRef: DatabaseReference { return self.database.child(self._path) }
static var storage: StorageReference { return Storage.storage().reference() }
static var storageRef: StorageReference { return self.storage.child(self._path) }
}
12 changes: 6 additions & 6 deletions Salada/Salada+Datasource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public class Datasource<Parent, Child> where Parent: Referenceable, Parent: Sala

/// DatabaseReference

public var databaseRef: FIRDatabaseReference { return FIRDatabase.database().reference() }
public var databaseRef: DatabaseReference { return Database.database().reference() }

public var count: Int { return pool.count }

fileprivate(set) var parentRef: FIRDatabaseReference
fileprivate(set) var parentRef: DatabaseReference

fileprivate(set) var reference: FIRDatabaseReference
fileprivate(set) var reference: DatabaseReference

fileprivate(set) var parentKey: String

Expand All @@ -74,7 +74,7 @@ public class Datasource<Parent, Child> where Parent: Referenceable, Parent: Sala
}
}

private var addReference: FIRDatabaseQuery?
private var addReference: DatabaseQuery?

fileprivate var addedHandle: UInt?
fileprivate var changedHandle: UInt?
Expand Down Expand Up @@ -108,7 +108,7 @@ public class Datasource<Parent, Child> where Parent: Referenceable, Parent: Sala
guard let strongSelf = self else { return }

// add
var addReference: FIRDatabaseQuery = strongSelf.reference
var addReference: DatabaseQuery = strongSelf.reference
if let fiarstKey: String = strongSelf.pool.first {
addReference = addReference.queryOrderedByKey().queryStarting(atValue: fiarstKey)
}
Expand Down Expand Up @@ -194,7 +194,7 @@ public class Datasource<Parent, Child> where Parent: Referenceable, Parent: Sala
return
}

var reference: FIRDatabaseQuery = self.reference.queryOrderedByKey()
var reference: DatabaseQuery = self.reference.queryOrderedByKey()
var limit: UInt = limit
if let lastKey: String = lastKey {
reference = reference.queryEnding(atValue: lastKey)
Expand Down
Loading

0 comments on commit dcb57ea

Please sign in to comment.