Skip to content

Commit

Permalink
Updated changelog and readme for RxLifecycle 2
Browse files Browse the repository at this point in the history
  • Loading branch information
dlew committed Nov 7, 2016
1 parent 33dd53f commit bac6f42
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 35 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 2.0 (*unreleased*)

This major revision was made to support RxJava 2. RxLifecycle 2.0 lives in a new namespace and package
names so that it can work side-by-side with RxLifecycle 1.0 (while transitioning).

The biggest change is that `LifecycleTransformer` now works for *all* RxJava types:
`Observable`, `Flowable`, `Single`, `Maybe` and `Completable`. Unlike before, there's
no extra steps you have to take to make it work with types other than `Observable`.

- [#167](https://github.com/trello/RxLifecycle/pull/167): Upgrade to RxJava 2
- [#169](https://github.com/trello/RxLifecycle/pull/169): Move to com.trello.rxlifecycle2
- [#170](https://github.com/trello/RxLifecycle/pull/170): Added Maybe support
- [#172](https://github.com/trello/RxLifecycle/pull/172): Added Flowable support

## 1.0 (2016-11-03)

First and (hopefully) final release of 1.x branch!
Expand Down
67 changes: 32 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# RxLifecycle

The utilities provided here allow for automatic completion of sequences based on `Activity` or `Fragment`
lifecycle events. This capability is useful in Android, where incomplete subscriptions can cause memory leaks.
This library allows one to automatically complete sequences based on a second lifecycle stream.

This capability is useful in Android, where incomplete subscriptions can cause memory leaks.

## Usage

You must provide an `Observable<ActivityEvent>` or `Observable<FragmentEvent>` that gives
RxLifecycle the information needed to complete the sequence at the correct time.
You must start with an `Observable<T>` representing a lifecycle stream. Then you use `RxLifecycle` to bind
a sequence to that lifecycle.

You can bind when the lifecycle emits anything:

```java
myObservable
.compose(RxLifecycle.bind(lifecycle))
.subscribe();
```

You can then end the sequence explicitly when an event occurs:
Or you can bind to when a specific lifecyle event occurs:

```java
myObservable
Expand All @@ -28,22 +37,10 @@ It assumes you want to end the sequence in the opposing lifecycle event - e.g.,
terminate on `STOP`. If you subscribe after `PAUSE`, it will terminate at the next destruction event (e.g.,
`PAUSE` will terminate in `STOP`).

## Single and Completable

RxLifecycle supports both `Single` and `Completable` via the `LifecycleTransformer`. You can
convert any returned `LifecycleTransformer` into a `Single.Transformer` or `Completable.Transformer`
via the `forSingle()` and `forCompletable()` methods:

```java
mySingle
.compose(RxLifecycleAndroid.bindActivity(lifecycle).forSingle())
.subscribe();
```

## Providers

Where do the sequences of `ActivityEvent` or `FragmentEvent` come from? Generally, they are provided by
an appropriate `LifecycleProvider<T>`. But where are those implemented?
Where do lifecycles come from? Generally, they are provided by an appropriate `LifecycleProvider<T>`. But where are
those implemented?

You have a few options for that:

Expand Down Expand Up @@ -82,7 +79,20 @@ public class MyActivity extends NaviActivity {
}
```

If you want some Kotlin goodness, you can use built-in extensions:
## Unsubscription

RxLifecycle does not actually unsubscribe the sequence. Instead it terminates the sequence. The way in which
it does so varies based on the type:

- `Observable`, `Flowable` and `Maybe` - emits `onCompleted()`
- `Single` and `Completable` - emits `onError(CancellationException)`

If a sequence requires the `Subscription.unsubscribe()` behavior, then it is suggested that you manually handle
the `Subscription` yourself and call `unsubscribe()` when appropriate.

## Kotlin

The rxlifecycle-kotlin module provides built-in extensions to the base RxJava types:

```java
myObservable
Expand All @@ -94,19 +104,10 @@ myObservable
.subscribe { }
```

## Unsubscription

RxLifecycle does not actually unsubscribe the sequence. Instead it terminates the sequence. The way in which
it does so varies based on the type:

- `Observable` - emits `onCompleted()`
- `Single` and `Completable` - emits `onError(CancellationException)`

If a sequence requires the `Subscription.unsubscribe()` behavior, then it is suggested that you manually handle
the `Subscription` yourself and call `unsubscribe()` when appropriate.

## Installation

RxLifecycle2 is currently only on OSS snapshot repository (https://oss.sonatype.org/content/repositories/snapshots/).

```gradle
compile 'com.trello.rxlifecycle2:rxlifecycle:2.0-SNAPSHOT'
Expand All @@ -123,10 +124,6 @@ compile 'com.trello.rxlifecycle2:rxlifecycle-navi:2.0-SNAPSHOT'
compile 'com.trello.rxlifecycle2:rxlifecycle-kotlin:2.0-SNAPSHOT'
```

## Related Libraries

- [Android-Lint-Checks](https://github.com/vokal/Android-Lint-Checks) - Contains an RxLifecycle Lint check.

## License

Copyright (C) 2016 Trello
Expand Down

0 comments on commit bac6f42

Please sign in to comment.