Giter Club home page Giter Club logo

hermesnetwork's Introduction

HermesNetwork

Carthage compatible CI Status Version License Platform

HermesNetwork is the concrete implementation of an isolated/testable networking layer written in Swift.

Architecture Design

Current version is based upon the network architecture design described in: "Network Layers in Swift (Updated)" written by me.

Used Libraries

While the theory behind this approach is independent from the tool used, in order to give a complete out-of-box approach I’ve used the following libraries:

  • Networking support: in this example the Service implementation uses Alamofire. Switching to NSURLSession is pretty easy and, in fact, suggested.
  • Async/Promise support: I love promises (at least until we’ll get something better with Swift 5) because they are clean, simple and offer a strong error handling mechanism. Our networking layer uses Hydra, that recently hits the 1.0 milestone.
  • JSON: The higher level (near your app) of the architecture offer out-of-box JSON support with JSONOperation class: everything about JSON was offered by SwiftyJSON, probability the best library for these stuff.

Installation

You can install Swiftline using CocoaPods, carthage and Swift package manager

CocoaPods

use_frameworks!
pod 'HermesNetwork'

Carthage

github 'malcommac/HermesNetwork'

Swift Package Manager

Add swiftline as dependency in your Package.swift

import PackageDescription

let package = Package(name: "YourPackage",
dependencies: [
.Package(url: "https://github.com/malcommac/HermesNetwork.git", majorVersion: 0),
]
)

hermesnetwork's People

Contributors

malcommac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hermesnetwork's Issues

Encoding dictionary as body

In the requestBody init, if I want to use a parameters string in the body field, it encodes the dictionary with a leading '?' which results in a bad request. Need an option to pass the param dictionary into body without that encoding.... I may submit one but not yet.

cachedJSON function Compile Error

This function below in the response protocol gives the following compile error: 'Call can throw, but it is not marked with 'try' and the error is not handled'

   private lazy var cachedJSON: JSON = {
        return JSON(data: self.data ?? Data())
    }()

Caching

Hey @malcommac,
awesome post, and exploration of networking part. I'm trying to implement cacheable operation and faced with one issue:

  1. I put my cache check and loading code right before I make a network api call
  2. If cache has a valid value then it resolves current promise with this value
  3. But after that when I receive an updated data neither catch nor then are called

Tried to dig inside Promise implementation in Hydra and found that the reason is that in Observer call method it falls into a default case and does nothing.

What I'm doing wrong and what do you think might be the right way?

Dependency Injection

Hi! I like this approach, however, there is a confusing moment.

Do i really need to inject one "Service" to all view controllers who needs to communicate with API if the only purpose of him is be passed to operation? And i also need to create an instances of JSONOperation inside my VC, and there is no way to injecting them, which is also doesn't feel good.

Is there a way to use that in more SOA style?

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.