let urlString = "https://httpbin.org/get"
let request = MRequest {
RUrl(urlString)
RPath(path)
Rbody(data)
REncoding(JSONEncoding.default)
RMethod(.get)
RHeaders()
RQueryItem()
RQueryItems()
/// somthing else
}
let socket = MSocket {
RUrl(urlString)
RPath(path)
Rbody(data)
REncoding(JSONEncoding.default)
RMethod(.get)
RHeaders()
RQueryItem()
RQueryItems()
/// somthing else
}
socket.write(string: "something")
let socketIO = MSocketIO(withSourceURL: URL(urlString: "")!, timeout: 15, connectparams: [:])
socketIO.on("event")
- Async
/// Data
let data = try await request.data
/// String
let string = try await request.string
/// Result<Data, AFError>
let result = await request.resultData
/// Result<String, AFError>
let result = await request.resultString
/// DataTask<Data>
let data = await request.serializingData
/// DataTask<String>
let string = await request.serializingString
- 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)
}
- CURL
let request: = ...
request
.printCURLRequest() // -> Self
request
.cURLDescription { curl in
// Todo with curl
} // -> Self
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"))
]