Spider 0.1.5

Spider 0.1.5

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Apr 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Dmitriy Shulzhenko.



Spider 0.1.5

  • By
  • Dmitriy Shulzhenko

Spider

[![CI Status](http://img.shields.io/travis/Dmitriy Shulzhenko/Spider.svg?style=flat)](https://travis-ci.org/Dmitriy Shulzhenko/Spider)

Update your model more easily. With cleaner architecture in your project.

Example

//sends http request, handles response, deletes old data and writes a new one

self.spider.request().delete().write().execute()

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

To use Spider you have to conform these protocols

// This is your storage for any network responce
// Storage will be used to update model

@objc public protocol TempObjectStorageProtocol: class{}
// Entity object. Can be subclass of NSManagedObject, or smth else

@objc public protocol EntityProtocol {

@objc static var entityName: String { get }

// Entity that contains some data (NSData, Image, ets.)

@objc optional var dataRemoutePaths: [String] { get }

@objc optional var dataNames: [String] { get }

}
// Persistant storage controller. E.g. Core data stack controller or other.

@objc public protocol PersistentStorageControllerProtocol {

@objc optional func update(name: String, with objects: TempObjectStorageProtocol)

@objc optional func remove(name: String, new objects: TempObjectStorageProtocol)

@objc optional func fetchWithoutData(name: String) -> [EntityProtocol]?

@objc optional func write(data dataStore: [TempObjectStorageProtocol], completed:((_ error: Error?) -> Void))

//    @objc func delete(data named: String, completed:((_ error: Error?) -> Void))

@objc optional func get(data named: String) -> Data?

}
// Network manager

public typealias NetworkResponseBlock = (_ objects: TempObjectStorageProtocol? , _ error: Error? ) -> (Void)

@objc public protocol NetworkControllerProtocol {

@objc func executeRequest(_ request: URLRequest,
response: @escaping NetworkResponseBlock) -> URLSessionTask

}

Installation

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

pod 'Spider'

Author

Dmitriy Shulzhenko, [email protected]

License

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