ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - yangKJ/RxNetworks: ๐Ÿงš MVP Network Api library. ๆ’ไปถ็‰ˆ็ฝ‘็ปœๅŸบ็ก€ๆžถๆž„๏ผŒๆ”ฏๆŒๅ“ๅบ”ๅผใ€‚
๐Ÿงš MVP Network Api library. ๆ’ไปถ็‰ˆ็ฝ‘็ปœๅŸบ็ก€ๆžถๆž„๏ผŒๆ”ฏๆŒๅ“ๅบ”ๅผใ€‚. Contribute to yangKJ/RxNetworks development by creating an account on GitHub.
Visit Site

GitHub - yangKJ/RxNetworks: ๐Ÿงš MVP Network Api library. ๆ’ไปถ็‰ˆ็ฝ‘็ปœๅŸบ็ก€ๆžถๆž„๏ผŒๆ”ฏๆŒๅ“ๅบ”ๅผใ€‚

GitHub - yangKJ/RxNetworks: ๐Ÿงš MVP Network Api library. ๆ’ไปถ็‰ˆ็ฝ‘็ปœๅŸบ็ก€ๆžถๆž„๏ผŒๆ”ฏๆŒๅ“ๅบ”ๅผใ€‚

Booming

Carthage compatible CocoaPods Compatible CocoaPods Compatible CocoaPods Compatible Platform

Booming is a base network library for Swift. Developed for Swift 5, it aims to make use of the latest language features. The framework's ultimate goal is to enable easy networking that makes it easy to write well-maintainable code.

RxNetworks is a declarative and reactive networking library for Swift.

๐Ÿงš. RxSwift + Moya + HandyJSON / Codable + Plugins.๐Ÿ‘’๐Ÿ‘’๐Ÿ‘’


English | ็ฎ€ไฝ“ไธญๆ–‡

This is a network api set of infrastructure based on Moya, also support responsive network with RxSwift.

Features

At the moment, the most important features of Booming can be summarized as follows:

  • Support reactive network requests combined with RxSwift.
  • Support for OOP also support POP network requests.
  • Support data parsing with HandyJSON and Codable.
  • Support simple customization of various network plugins for Moya.
  • Support uploading and downloading files or resources plugin.
  • Support configuration of general request and path, general parameters, etc.
  • Support for added default plugins with BoomingSetup.basePlugins.
  • Support authorization certificate plugin with Alamofire RequestInterceptor.
  • Support automatic managed loading plugins hud.
  • Support token plugin validation and automatically retries new token requests.
  • Support shared plugin that do not request the same network repeatedly.
  • Support separate plugin library, eg: Loading / AnimatedLoading / Cache.
  • Support 18 plugins have been packaged for you to use.

Usages

How to use CODE_OF_CONDUCT.

SharedAPI.userInfo(name: "yangKJ").request(successed: { response in
    // do somthing..
}, failed: { error in
    print(error.localizedDescription)
})

or use async/await with swift 5.5

Task {
    do {
        let response = try await LoadingAPI.test2("666").requestAsync()
        let json = response.bpm.mappedJson
        // do somthing..
        let model = LoadingModel.deserialize(from: json, designatedPath: "data")
    } catch {
        block(error.localizedDescription)
    }
}

Plugins

CocoaPods Compatible CocoaPods Compatible CocoaPods Compatible

This module is mainly based on moya package network related plugins.

  • At present, 14 plugins have been packaged for you to use:
    • Header: Network HTTP Header Plugin.
    • Authentication: Interceptor plugin.
    • Debugging: Network printing, built in plugin.
    • GZip: Network data unzip plugin.
    • Shared: Network sharing plugin.
    • Files: Network downloading files And Uploading resources plugin.
    • Token: Token verify plugin.
    • Ignore: Ignore plugin, the purpose is to ignore a plugin in this network request.
    • CustomCache: Custom network data caching plugin.
    • Cache: Network data cache plugin.
    • Lottie: Animation loading plugin based on lottie.

For ios platform:

If you want to use token plugin and auth plugin you can refer to the project use case.

  • Auth: Authorization plugin.

๐ŸŽท Simple to use, implement the protocol method in the API protocol, and then add the plugin to it:

var plugins: APIPlugins {
    let cache = NetworkCachePlugin.init()
    let loading = NetworkLoadingPlugin.init()
    let warning = NetworkWarningPlugin.init()
    let shared = NetworkSharedPlugin.init()
    let gzip = NetworkGZipPlugin.init()
    return [loading, cache, warning, shared, gzip]
}

RxSwift

This module mainly supports responsive data binding.

func request(_ count: Int) -> Observable<[CacheModel]> {
    CacheAPI.cache(count).request()
        .deserialized(ApiResponse<[CacheModel]>.self)
        .compactMap { $0.data }
        .observe(on: MainScheduler.instance)
        .catchAndReturn([])
}

HollowCodable

HollowCodable is a codable customization using property wrappers library for Swift.

This module is serialize and deserialize the data, Replace HandyJSON.

๐ŸŽท Example of use in conjunction with the network part:

func request(_ count: Int) -> Observable<[LoadingModel]> {
    CodableAPI.cache(count)
        .request(callbackQueue: DispatchQueue(label: "request.codable"))
        .deserialized(ApiResponse<[LoadingModel]>.self)
        .compactMap({ $0.data })
        .observe(on: MainScheduler.instance)
        .catchAndReturn([])
}
public extension Observable where Element: Any {
    
    @discardableResult func deserialized<T>(_ type: T.Type) -> Observable<T> where T: HollowCodable {
        return self.map { element -> T in
            return try T.deserialize(element: element)
        }
    }
    
    @discardableResult func deserialized<T>(_ type: [T].Type) -> Observable<[T]> where T: HollowCodable {
        return self.map { element -> [T] in
            return try [T].deserialize(element: element)
        }
    }
    
    @discardableResult func deserialized<T>(_ type: T.Type) -> Observable<ApiResponse<T.DataType>> where T: HasResponsable, T.DataType: HollowCodable {
        return self.map { element -> ApiResponse<T.DataType> in
            return try T.deserialize(element: element)
        }
    }
    
    @discardableResult func deserialized<T>(_ type: T.Type) -> Observable<ApiResponse<[T.DataType.Element]>> where T: HasResponsable, T.DataType: Collection, T.DataType.Element: HollowCodable {
        return self.map { element -> ApiResponse<[T.DataType.Element]> in
            return try T.deserialize(element: element)
        }
    }
}

HandyJSON

โš ๏ธ Note: This module is not recommended because it has stopped maintenance.

  • Roughly divided into the following 3 parts:

๐ŸŽท Example of use in conjunction with the network part:

func request(_ count: Int) -> Driver<[CacheModel]> {
    CacheAPI.cache(count).request()
        .asObservable()
        .mapHandyJSON(HandyDataModel<[CacheModel]>.self)
        .compactMap { $0.data }
        .observe(on: MainScheduler.instance)
        .delay(.seconds(1), scheduler: MainScheduler.instance)
        .asDriver(onErrorJustReturn: [])
}

CocoaPods

CocoaPods is a dependency manager. For usage and installation instructions, visit their website. To integrate using CocoaPods, specify it in your Podfile:

pod 'Booming'

You should define your minimum deployment target explicitly, like:

platform :ios, '11.0'

If you want import cache plugin:

pod 'NetworkCachePlugin'

If you want import loading plugin:

pod 'NetworkHudsPlugin'

If you wang using Codable:

pod 'HollowCodable'

If responsive networking is required:

pod 'RxNetworks/RxSwift'

For other plugins and modules excluded, please read the podspec file.

Remarks

The general process is almost like this, the Demo is also written in great detail, you can check it out for yourself.๐ŸŽท

BoomingDemo

Tip: If you find it helpful, please help me with a star. If you have any questions or needs, you can also issue.

Thanks.๐ŸŽ‡

About the author

Buy me a coffee or support me on GitHub.

Alipay or WeChat. Thanks.


License

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


More Resources
to explore the angular.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory