Coder Social home page Coder Social logo

brouter's Introduction

BRouter 是一个学习项目组件化的开源项目。

项目里面尽量使用最简单的代码来实现组件化的功能,实现的原理会参考其他开源项目,比如,ARouter,这也是这个项目叫做 BRouter 的原因,不过随着项目功能的扩展,实现原理已经不仅仅局限于 ARouter 了。

项目里面不仅实现了功能,还分析了其他开源下项目的实现原理,而且还将实现过程记录为文档,便于理解。

项目app预览

项目如何运行

  • 如果你在项目里面使用了插件注册的方式,如下

    BRouter.init(this, true);

    需要注意: 因为有gradle插件,且工程使用的是本地maven依赖,所以需要先将 brouter_api 的插件发布出来,然后才能使用。 点击 brouter_api -> Tasks -> upload -> uploadArchives 即可将插件发布到项目下的 maven/repository 仓库里面,然后项目即可正常编译。

    然后,将 app 下的 build.gradle 的 //apply plugin: 'brouter' 这行注释打开

  • app 里面使用了代码隔离插件,所以也需要先将该插件发布到本地(发布的时候,可以先将对应的使用到该插件代码的位置注释掉,否则会无法同步):

    点击 code-isolation -> Tasks -> upload -> uploadArchives 即可将插件发布到项目下的 maven/repository 仓库里面,然后项目即可正常编译。

功能实现原理

  1. 组件跳转

  2. 组件路由懒加载

  3. 参数传递与注入

  4. 组件的生命周期分发

  5. 跳转拦截器

  6. 组件提供外部服务

  7. 获取组件Fragment

  8. 组件独立运行

  9. 组件代码隔离

  10. 组件之间公用代码下沉问题解决方案

  11. 注解处理器

brouter's People

Contributors

aprz512 avatar wood-water-peng avatar

Stargazers

Buerck avatar  avatar 阿喵 avatar  avatar  avatar  avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

whysqwhw

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.