/AnyRouter

Primary LanguageSwiftMIT LicenseMIT

AnyRouter

基于路由的模块间通信方案 CI Status Version License Platform

Example

RouterCenter.default.register(url: "https://m.baidu.com", handlerClass: ClassRouterHandler.self)
RouterCenter.default.register(url: "https://m.init.com", handlerObject: handler)
RouterCenter.default.register(url: "https://testvc", viewController: TestRouterViewController.self)
struct ObjectRouterHandler : RouterHandlerProtocol{
    func handleRouter(url: String, parameters: [String : Any]?, completion: ((RouterResponseProtocol) -> Void)?) {
        completion?(RouterResponse(data: "ObjectRouterHandler-success"))
    }
}

struct ClassRouterHandler : RouterStaticHandlerProtocol {
    static func handleRouter(url: String, parameters: [String : Any]?, completion: ((RouterResponseProtocol) -> Void)?) {
        completion?(RouterResponse(data: "ClassRouterHandler-success"))
    }
}

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

Requirements

Installation

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

pod 'AnyRouter'

Author

hsh, qinyue0306@163.com

License

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