Skip to content

This is an extension to Firebase's HTTPSCallableResult which allows you to decode an API result from type HTTPSCallableResult to any data type in Swift using decodable

License

Notifications You must be signed in to change notification settings

jamesw3712/HTTPSCallableResultDecoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

HTTPSCallableResultDecoder

This is an extension to Firebase's HTTPSCallableResult which allows you to decode an API result from type HTTPSCallableResult to any data type in Swift using decodable

Installation

Just simply download the source file and add it to your xcode project in any directory you would like

Usage

        funtions.httpsCallable(funtionName).call(parameters) { (result, error) in
                    if let error = error as NSError?{
                        print(error.localizedDescription)
                        callback(posts)
                        return
                    }

                    //THIS IS ALL YOU NEED TO DECODE A RESULT FROM A FIREBASE API!
                    if let postsObjects: [UserPost.Post] = result?.getDecodedResult(decodeTo: [UserPost.Post].self){
                        //DO STUFF WITH YOUR NEW ARRAY OF POSTS!
                    }

                    posts.sort(by: self.sortByTime(this:that:))
                    callback(posts)

           }

About

This is an extension to Firebase's HTTPSCallableResult which allows you to decode an API result from type HTTPSCallableResult to any data type in Swift using decodable

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages