Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BRouter

CI Status Version License Platform

Overview

一个用来做组件之间通信的Router, 开发思路来自MGJRouter。 感谢蘑菇街的开源代码。 此库提供的功能:

  • 可以自由的注册Url 和 对应的响应方法
  • 使用协议的方式,简化控制器之间的跳转,注册。

Usage

自定义注册

///自定义,方式注册
BRouter.register(url: "appscheme://user/getUserInfo") { (query, extend, callback) in
    //打印参数
    print(query)
    print(extend)
    //query, extend, callback
    //模拟网络请求
    DispatchQueue.global().async {
        sleep(2)
        DispatchQueue.main.async {
            callback?(["result":"success"])
        }
    }
}

///处理 url
BRouter.handle(url: "appscheme://user/getUserInfo?userId=121", extened: ["Image":1]) { (paramters) in
    ///回调结果参数
    print("请求结果 \(paramters)")
}

页面注册

///注册页面跳转,跳转的页面YourViewController 需要实现PageRouterable 用来接收参数
BRouter.map(url: "appscheme://item/detail", page: YourViewController.self)

///拿到配置的url, 跳转到匹配的页面
let url = "appscheme://item/detail?id=1&name=小飞"
BRouter.open(url: url, from: self.navigationController)

Requirements

  • Xcode 10.2+
  • Swift 5.0+ (for latest release)

Installation

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

pod 'BRouter'

Author

owliVendy, 446200660@qq.com

License

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

About

一个 高度自由的路由

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages