GithubHelp home page GithubHelp logo

rorodriguez116 / portal Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 971 KB

A simple and handy Swift Firebase abstraction layer that lets you focus on creating awesome apps quickly.

License: MIT License

Ruby 14.64% Swift 85.36%

portal's Introduction

Portal

Version License Platform

Portal is a simple abstraction layer of FirebaseFirestore and FirebaseAuth, it saves you a lot of work by automatycally parsing document snapshots into your data layer model by using generics at its core. Portal also allows you to use FirebaseAuth with a very easy to use API to sign-in & sign-up new users into FirebaseAuth and create its mirror representation into your database all done by PortalAuth while maintaining your specified data layer model.

Requirements

  • iOS 12.0+

Installation

Portal is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Portal'

Usage

Portal uses generics to identify what model it should use with your database path, to do so it uses generics at is core. Models used by Portal must conform to the PortalModel protocol.

Creating a Model

Let's declare a struct Pet which will be used as the base data layer model for this example.

PortalModel protocol only requirement is to declare a get only portalIdentifier variable. This variable will be used by Portal to create your model at a path that matches its unique identifier.

struct Pet: PortalModel {

    var id: String
    let name: String
    let age: Int
    
    var portalIdentifier: String {
        return id 
    }
}

Creating a Portal

To instantiate a new Portal you need to specify what model it will use and at what path in your database.

let portal = Portal<Pet>(path: "pets")

Portal Events

To use Portal's features you must access them by the .event function. In this example we'll use the .new event to create a new document with the structure of type Pet in your database in the path pets

let portal = Portal<Pet>(path: "pets")
let myPet = Pet(id: "MyPetID", name: "Monchi", age: 3)

portal.event(.new(myPet)) { (result) in
    switch result { 
        case .success: print("Success! Your data has been succesfully created")
        case .failure(let error): print(error)
    }
}

License

Portal is available under the MIT license. See the LICENSE file for more info.

portal's People

Contributors

rorodriguez116 avatar

Stargazers

Alessandro Aresta avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.