Swiftpack.co - FullStack-Swift/swift-networking as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by FullStack-Swift.
FullStack-Swift/swift-networking v1.0.0
Create Publisher in Combine, Observable in RxSwift SignalProducer in ReactiveSwift, Build Networking with Declarative Programming like SwiftUI
⭐️ 1
🕓 8 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/FullStack-Swift/swift-networking.git", from: "v1.0.0")

Networking

Making Requests

let urlString = "https://httpbin.org/get"
let request = MRequest {
  RMethod(.get)
  RUrl(urlString: urlString)
  /// somthing else
}

let socket = MSocket {
  RUrl(urlString: urlString)
  /// somthing else
}

socket.write(string: "something")

let socketIO = MSocketIO(withSourceURL: URL(urlString: "")!, timeout: 15, connectparams: [:])
socketIO.on("event")

Response Handling

  • Combine
request.sink { response in
  debugPrint(response)
}

socket.sink { response in
  debugPrint(response)
 }
 
 socketIO.on("event").sink { dict in
  debugPrint(dict)
}
  • ReactiveSwift
request.producer.startWithValues { response in
  debugPrint(response)
}

socket.producer.startWithValues { response in
  debugPrint(response)
}

socketIO.on("event").producer.startWithValues { dict in
  debugPrint(dict)
}
  • RxSwift
request.subscribe { response in
  debugPrint(response)
}

socket.subscribe { response in
  debugPrint(response)
}

socketIO.on("event").subscribe { dict in 
  debugPrint(dict)
}

Installation

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

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

dependencies: [
    .package(url: "https://github.com/FullStack-Swift/Networking", .upToNextMajor(from: "1.0.0"))
]

Example

https://github.com/FullStack-Swift/TodoList

GitHub

link
Stars: 1
Last commit: 5 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Related Packages

Release Notes

v1.0.0
1 year ago

Release

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics