
KComponent 它来啦. 从 2018.8 开始, Component 项目正式开源. 到目前已经 4 年的时间了. 这几年中, Component 不断升级优化. 最后趋于稳定.
为了组件化框架更好的发展, KComponent 继承了 Component 的优点, 升级为一个纯 Kotlin 的项目. 不再支持 Java, 注解驱动器也升级为 KSP
如果想要兼容 Java, 还请继续使用 Component , 如果你的项目是纯 Kotlin 项目, 请使用 KComponent
手动加载 反射 或者 自动加载 ASM 字节码
@RouterAnno(hostAndPath = "user/login",
)
class LoginAct: AppCompatActivity {@AttrValueAutowiredAnnolate init name: String@AttrValueAutowiredAnno("password")var password1: String? = nulloverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)Component.inject(target = this)// xxxxxx}}
Router
.with(context)
.hostAndPath("user/login")
.putString("name", "xiaojinzi")
.putString("password", "123456")
.forword()
更多的用法和更详细的解释请查看文档:路由跳转 和 路由标记 @RouterAnno 的使用
interface UserSpi {fun login(name: String, password: String)
}@ServiceAnno(UserSpi::class)
class UserSpiImpl : UserSpi {fun login(name: String, password: String) {// xxxx}
}
UserSpi::class.service()?.login(name = "xiaojinzi", password = "xxxxxx")
更多的用法和更详细的解释请查看文档:服务发现的使用 和 [服务的装饰增强](