All Projects → iAmrSalman → Dots

iAmrSalman / Dots

Licence: MIT license
Lightweight Concurrent Networking Framework

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Dots

Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+30488.57%)
Mutual labels:  tvos, watchos, carthage, swift-package-manager
Web3.swift
A pure swift Ethereum Web3 library
Stars: ✭ 295 (+742.86%)
Mutual labels:  tvos, watchos, carthage, swift-package-manager
Mechanica
A cross-platform library of Swift utils to ease your iOS | macOS | watchOS | tvOS and Linux development.
Stars: ✭ 27 (-22.86%)
Mutual labels:  tvos, watchos, carthage, swift-package-manager
Functionkit
A framework for functional types and operations designed to fit naturally into Swift.
Stars: ✭ 302 (+762.86%)
Mutual labels:  tvos, watchos, carthage, swift-package-manager
L10n Swift
Localization of the application with ability to change language "on the fly" and support for plural form in any language.
Stars: ✭ 177 (+405.71%)
Mutual labels:  tvos, watchos, carthage, swift-package-manager
Queuer
Queuer is a queue manager, built on top of OperationQueue and Dispatch (aka GCD).
Stars: ✭ 964 (+2654.29%)
Mutual labels:  tvos, watchos, carthage, swift-package-manager
Ducttape
📦 KeyPath dynamicMemberLookup based syntax sugar for Swift.
Stars: ✭ 138 (+294.29%)
Mutual labels:  tvos, watchos, carthage, swift-package-manager
Swiftframeworktemplate
A template for new Swift iOS / macOS / tvOS / watchOS Framework project ready with travis-ci, cocoapods, Carthage, SwiftPM and a Readme file
Stars: ✭ 527 (+1405.71%)
Mutual labels:  tvos, watchos, carthage, swift-package-manager
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (+351.43%)
Mutual labels:  tvos, watchos, carthage, swift-package-manager
Guitar
A Cross-Platform String and Regular Expression Library written in Swift.
Stars: ✭ 641 (+1731.43%)
Mutual labels:  tvos, watchos, carthage, swift-package-manager
Swiftlinkpreview
It makes a preview from an URL, grabbing all the information such as title, relevant texts and images.
Stars: ✭ 1,216 (+3374.29%)
Mutual labels:  tvos, watchos, carthage, swift-package-manager
Diff
Simple diff library in pure Swift
Stars: ✭ 110 (+214.29%)
Mutual labels:  tvos, watchos, carthage
Sdwebimagewebpcoder
A WebP coder plugin for SDWebImage, use libwebp
Stars: ✭ 101 (+188.57%)
Mutual labels:  tvos, watchos, carthage
Mixpanel
Unofficial Swift Mixpanel client
Stars: ✭ 93 (+165.71%)
Mutual labels:  tvos, watchos, carthage
Sqift
Powerful Swift wrapper for SQLite
Stars: ✭ 119 (+240%)
Mutual labels:  tvos, watchos, carthage
Surmagic
🚀 The better way to deal with Binary Frameworks on iOS, Mac Catalyst, tvOS, macOS, and watchOS. Create XCFrameworks with ease.
Stars: ✭ 119 (+240%)
Mutual labels:  tvos, watchos, swift-package-manager
Contentful.swift
A delightful Swift interface to Contentful's content delivery API.
Stars: ✭ 132 (+277.14%)
Mutual labels:  tvos, watchos, carthage
SwiftCurrent
A library for managing complex workflows in Swift
Stars: ✭ 286 (+717.14%)
Mutual labels:  tvos, watchos, swift-package-manager
Swiftyattributes
A Swifty API for attributed strings
Stars: ✭ 1,303 (+3622.86%)
Mutual labels:  tvos, watchos, carthage
Opencombine
Open source implementation of Apple's Combine framework for processing values over time.
Stars: ✭ 2,040 (+5728.57%)
Mutual labels:  tvos, watchos, swift-package-manager

Dots

CI Status Version License Platform

banner

Example

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

Requirements

  • iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+
  • Xcode 8.0+
  • Swift 4.0+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.1+ is required to build StorageManager.

To integrate StorageManager into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'Dots'
end

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate StorageManager into your Xcode project using Carthage, specify it in your Cartfile:

github "iAmrSalman/Dots" ~> 0.5.0

Run carthage update to build the framework and drag the built Dots.framework into your Xcode project.

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but StorageManager does support its use on supported platforms.

Once you have your Swift package set up, adding StorageManager as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/iAmrSalman/Dots.git", from: "0.5.0")
]

Usage

Making a Request

import Dots

Dots.defualt.request("<URL>") { (dot: Dot) in
    
  print(dot.response) // HTTP URL response
  print(dot.data)     // server data
  print(dot.error)    // Errors from request processing
  print(dot.json)     // JSON dictionary [String: Any]

}

HTTP Methods

The HTTPMethod enumeration lists the HTTP methods:

public enum HTTPMethod: String {
  case options = "OPTIONS"
  case get     = "GET"
  case head    = "HEAD"
  case post    = "POST"
  case put     = "PUT"
  case patch   = "PATCH"
  case delete  = "DELETE"
  case trace   = "TRACE"
  case connect = "CONNECT"
}

These values can be passed as the method argument to the request Function:

Dots.defualt.request("<URL>") // method defaults to `.get`
Dots.defualt.request("<URL>", method: .post)
Dots.defualt.request("<URL>", method: .put)
Dots.defualt.request("<URL>", method: .delete)

The request method parameter defaults to .get.

Parameter Encoding

GET Request With URL-Encoded Parameters

let parameters: Parameters = ["foo": "bar"]

Dots.defualt.request("<URL>", parameters: parameters) // defaults url encoding
Dots.defualt.request("<URL>", parameters: parameters, encoding: .url)

// <URL>?foo=bar

POST Request With URL-Encoded Parameters

let parameters: Parameters = [
  "foo": "bar",
  "baz": ["a", 1],
  "qux": [
    "x": 1,
    "y": 2,
    "z": 3
  ]
]

Dots.defualt.request("<URL>", method: .post, parameters: parameters) // defaults url encoding
Dots.defualt.request("<URL>", method: .post, parameters: parameters, encoding: .url)

//httpHeader: Content-Type: application/x-www-form-urlencoded; charset=utf-8

// HTTP body: foo=bar&baz[]=a&baz[]=1&qux[x]=1&qux[y]=2&qux[z]=3

POST Request With JSON-Encoded Parameters

let parameters: Parameters = [
  "foo": [1,2,3],
  "bar": [
    "baz": "qux"
  ]
]

Dots.defualt.request("<URL>", method: .post, parameters: parameters, encoding: .json)

//HTTP header: Content-Type: application/json

// HTTP body: {"foo": [1, 2, 3], "bar": {"baz": "qux"}}

HTTP Headers

Adding a custom HTTP header to a Request is supported directly in the global request method. This makes it easy to attach HTTP headers to a Request.

let headers: HTTPHeaders = [
  "Authorization": "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
  "Accept": "application/json"
]

Dots.defualt.request("<URL>", headers: headers)

Concurrency

Choosing between Asynchronous and Synchronous is supported

Dots.defualt.request("<URL>", concurrency: .async) // concurrency defaults to `.async`
Dots.defualt.request("<URL>", concurrency: .sync)

Maximum concurrent requests

Customizing Maximum concurrent requests executing simultaneously is supported.

The defualt is checking if device is on cellular connection, maximum concurrent requests is restricted to 2, while Wi-Fi is executing up to 6 simultaneous requests.

let customDots = Dots(maxConcurrentOperation: <Int>)
customDots.request("<URL>") 

Extensions

UIImageView

imageView.setImage(withURL: "<URL>")

Author

Amr Salman, [email protected]

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].