Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
ChangeLog Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
İbrahim Yilmaz committed Jul 20, 2019
1 parent 1a04d66 commit b52a955
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Changelog

## [Unreleased]
## [Development]
- ChangeLog updated for Non Null Observe.

## Bursa(0.0.2)
- Non Null Observe extension method is added.

## Bursa(0.0.1)
- Bintray Publish
- PublishLiveData and ReplayLiveData implemented
Expand Down
43 changes: 31 additions & 12 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ArchData
=======

ArchData provides two missing LiveData of Android Lifecycle Component.
ArchData provides two missing LiveData of Android Lifecycle Component and useful extension functions.

`MutableLiveData` shares only last state to its new observers when they start to observe.

Expand All @@ -15,6 +15,10 @@ Basically:
* `PublishLiveData` is `MutableLiveData`, which only notify its observers if there is an event after their starting of observation.
* `ReplayLiveData` is `MutableLiveData`, which only notify its observers for all previous events happened before their observation starts.

Extension Functions:

* `nonNullObserve` is extension function, which eliminates nullable invokes of Observer.


Usage
-----
Expand All @@ -27,27 +31,42 @@ Usage
```kotlin
val liveData = PublishLiveData<String>();
// observer1 will receive all events
liveData.observe(lifeCycleOwner,observer1);
liveData.postValue("one");
liveData.postValue("two");
liveData.observe(lifeCycleOwner,observer1)
liveData.postValue("one")
liveData.postValue("two")
// observer2 will only receive "three"
liveData.observe(lifeCycleOwner,observer2);
liveData.postValue("three");
liveData.observe(lifeCycleOwner,observer2)
liveData.postValue("three")
```

* **`ReplayLiveData`**

LiveData that buffers all items it observes and replays them to any `Observer` that subscribes.

```kotlin
val liveData = ReplayLiveData<String>();
liveData.postValue("one");
liveData.postValue("two");
liveData.postValue("three");
val liveData = ReplayLiveData<String>()
liveData.postValue("one")
liveData.postValue("two")
liveData.postValue("three")
// both of the following will get the events from above
liveData.observe(lifeCycleOwner,observer1);
liveData.postValue(lifeCycleOwner,observer2);
liveData.observe(lifeCycleOwner,observer1)
liveData.postValue(lifeCycleOwner,observer2)
```

* **`nonNullObserve`**

LiveData that buffers all items it observes and replays them to any `Observer` that subscribes.

```kotlin
viewModel.liveData.nonNullObserve(lifeCycleOwner,::methodInYourObserverClass)

...

fun methodInYourObserverClass(any: AnyParameter){
//Do something good!.
}

```

Download
--------
Expand Down

0 comments on commit b52a955

Please sign in to comment.