Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

WotCore/EventBus-ktx

Repository files navigation

API

EventBus-ktx

重点类说明

使用

订阅

// 订阅全局粘性
observeEvent<GlobalEvent>(isSticky = true) {
}
// 订阅全局非粘性
observeEvent<GlobalEvent> {
}
// 订阅activity粘性
observeEvent<ActivityEvent>(owner = activity as ComponentActivity, isSticky = true) {
}
// 订阅activity非粘性
observeEvent<ActivityEvent>(owner = activity as ComponentActivity) {
}
// 订阅fragment粘性
observeEvent<FragmentEvent>(owner = this@EventFragment, isSticky = true) { 
}
// 订阅fragment非粘性
observeEvent<FragmentEvent>(owner = this@EventFragment) {
}

发送

// 范围: 全局
postEvent(GlobalEvent("全局"))
// 范围: activity
postEvent(activity, ActivityEvent("activity"))
// 范围: fragment
postEvent(this@EventFragment, FragmentEvent("fragment"))

引入

添加仓库

在项目的 build.gradle 文件中配置仓库地址。

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

添加项目依赖

在需要添加依赖的 Module 下添加以下信息,使用方式和普通的远程仓库一样。

implementation 'com.github.yangsanning:EventBus-ktx:1.0.0'

About

让事件发送更简单

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /