GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - leavesczy/EventLiveData: Jetpack LiveData 功能扩展

This repository was archived by the owner on May 22, 2026. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

16 Commits
16 Commits

Folders and files

NameName
Last commit message
Last commit date
app
app
 
 
gradle/wrapper
gradle/wrapper
 
 
livedata
livedata
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
build.gradle.kts
build.gradle.kts
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
jitpack.yml
jitpack.yml
 
 
settings.gradle.kts
settings.gradle.kts
 
 

Repository files navigation

EventLiveData Maven Central

Jetpack LiveData 功能扩展,可自由选择是否接收黏性事件,也可自由选择是否扩大 observe 时的生命周期范围

导入依赖:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}

dependencies {
    implementation("io.github.leavesczy:event-livedata:latestVersion")
}

使用:

val eventLiveData = EventLiveData<String>()

//不接收黏性消息
//在 onStart 之后和 onStop 之前均能收到 Observer 回调,和 LiveData 一致
eventLiveData.observe(lifecycleOwner) {

}
//不接收黏性消息
//在 onCreate 之后和 onDestroy 之前均能收到 Observer 回调
eventLiveData.observe(lifecycleOwner, false) {

}
//不接收黏性消息
eventLiveData.observeForever {

}

//接收黏性消息
//在 onStart 之后和 onStop 之前均能收到 Observer 回调,和 LiveData 一致
eventLiveData.observeSticky(lifecycleOwner) {

}
//接收黏性消息
//在 onCreate 之后和 onDestroy 之前均能收到 Observer 回调
eventLiveData.observeSticky(lifecycleOwner, false) {

}
//接收黏性消息
eventLiveData.observeForeverSticky {

}

关联的文章:

  • Jetpack LiveData 的设计理念及改进

About

Jetpack LiveData 功能扩展

Topics

jetpack-livedata

Resources

Readme
Activity

Stars

20 stars

Watchers

1 watching

Forks

7 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.