A Extension of Firebase Realtime Database for use Codable on ref observer.
version 1.0.1
Firebase Codable can be install only with spm. Add this line to your Package.swift file
.package(url: "https://github.com/popina/FirCodable.git", .upToNextMajor(from: "1.0.1")),-
you can use
DataSnapshotDecoderto transform Datasnapshot to class or struct conform to Codable protocol and useDataSnapshotEncoderto transform class or struct conform to Codable protocol to Dictionary. -
use function on
DatabaseReferencefor listen all change:func observe<C: Codable>(_ type: DataEventType, completion: @escaping(_ value: C?, _ error: Error?) -> Void) func observeSingleEvent<C: Codable>(_ type: DataEventType, completion: @escaping(_ value: C?, _ error: Error?) -> Void)