skydoves/lazybones
😴 A lazy and fluent syntactic sugar for observing Activity, Fragment, and ViewModel lifecycles with lifecycle-aware properties.
5 Releases
Latest: 4y ago
1.0.4Latest
📋 What's Changed
- Added Proguard Rules for `lazybones-viewmodel` by @skydoves in https://github.com/skydoves/Lazybones/pull/6
- Full Changelog: https://github.com/skydoves/Lazybones/compare/1.0.3...1.0.4
1.0.3
📦 Introduce
- ```kotlin
- class MyViewModel : ViewModel() {
- private val lifecycleAwareCompositeDisposable = lifecycleAware { CompositeDisposable() }
- .onInitialize {
- Log.d(TAG, "ViewModel is initialized")
- }.onClear {
- Log.d(TAG, "ViewModel is cleared")
- dispose() // dispose CompositeDisposable when viewModel is getting cleared
- + 3 more
📋 What's Changed
- Migrate to Lifecycle 2.4.0 by @skydoves in https://github.com/skydoves/Lazybones/pull/3
- New Feature: lazybones-viewmodel by @skydoves in https://github.com/skydoves/Lazybones/pull/4
- Implement lazybones viewmodel extensions by @skydoves in https://github.com/skydoves/Lazybones/pull/5
- Full Changelog: https://github.com/skydoves/Lazybones/compare/1.0.2...1.0.3
1.0.2
📦 Coroutines and Flow
- Add a dependency code to your module's `build.gradle` file.
- ```gradle
- dependencies {
- implementation "androidx.lifecycle:lifecycle-runtime-ktx:$versions.lifecycle" // over the 2.4.0-alpha01
- }
- ```
- ```kotlin
- private val job: Job by lifecycleAware {
- + 23 more
✨ addOnRepeatingJob
- > Launches and runs the given block in a coroutine when this LifecycleOwner's Lifecycle is at least at state. The launched coroutine will be canceled when the lifecycle state falls below the state.
- We can collect a flow on the coroutines lifecycle scope and cancel it automatically if the lifecycle falls below that state, and will restart if it's in that state again.
- ```kotlin
- private val job: Job by addOnRepeatingJob(Lifecycle.State.CREATED, simpleFlow()) {
- // collected value from the fetchesDataFlow()
- }.lazy()
- ```
1.0.1
📋 Changes
- The lifecycle related to `lifecycleAware` functionalities receives the parameter as applied.
- Implemented LifecycleAwareProperty's kotlin dsl way for observing.
1.0.0
Published the first version `1.0.0`.
