-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rxlifecycle-kotlin module added with bind() syntax #78
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,15 @@ public class MyActivity extends NaviActivity { | |
} | ||
``` | ||
|
||
If you want some kotlin goodness, you can use bind() syntax | ||
|
||
```java | ||
myObservable | ||
.bind(myView) //bind(myRxActivity or myRxFragment) | ||
.subscribe() | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exatra newline here. |
||
``` | ||
|
||
## Unsubscription | ||
|
||
RxLifecycle does not actually unsubscribe the sequence. It terminates it by emitting `onCompleted()`, which ends the | ||
|
@@ -91,6 +100,9 @@ compile 'com.trello:rxlifecycle-components:0.4.0' | |
|
||
// If you want to use Navi for providers | ||
compile 'com.trello:rxlifecycle-navi:0.4.0' | ||
|
||
// If you wat to use Kotlin syntax | ||
compile 'com.trello:rxlifecycle-kotlin:0.4.0' | ||
``` | ||
|
||
## License | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
buildscript { | ||
ext { | ||
//version here to share between build script and projects | ||
//todo https://github.com/JetBrains/kotlin/pull/775 : remove if it will be merged | ||
verKotlin = '1.0.0-rc-1036' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kotlin 1.0 final got released, should update here. |
||
} | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:1.5.0' | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$verKotlin" | ||
} | ||
} | ||
|
||
|
@@ -22,6 +28,7 @@ ext { | |
rxJava = 'io.reactivex:rxjava:1.0.16' | ||
rxBinding = 'com.jakewharton.rxbinding:rxbinding:0.3.0' | ||
navi = 'com.trello:navi:0.1.3' | ||
kotlinStdlib = "org.jetbrains.kotlin:kotlin-stdlib:$verKotlin" | ||
appCompat = 'com.android.support:appcompat-v7:23.1.1' | ||
junit = 'junit:junit:4.12' | ||
mockito = 'org.mockito:mockito-core:1.10.19' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
|
||
android { | ||
compileSdkVersion rootProject.ext.compileSdkVersion | ||
buildToolsVersion rootProject.ext.buildToolsVersion | ||
|
||
defaultConfig { | ||
minSdkVersion rootProject.ext.minSdkVersion | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
compile kotlinStdlib | ||
compile project(':rxlifecycle') | ||
|
||
compile rootProject.ext.rxJava | ||
|
||
compile rootProject.ext.appCompat | ||
|
||
testCompile rootProject.ext.junit | ||
testCompile rootProject.ext.mockito | ||
testCompile rootProject.ext.robolectric | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this part of the project really need all these dependencies? I'm guessing it only needs the top two. |
||
} | ||
|
||
apply from: "$rootDir/gradle/artifacts.gradle" | ||
apply from: "$rootDir/gradle/gradle-mvn-push.gradle" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
POM_NAME=RxLifecycle-Kotlin | ||
POM_DESCRIPTION=RxLifecycle-Kotlin | ||
POM_ARTIFACT_ID=rxlifecycle-Kotlin | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No capital 'k' here. |
||
POM_PACKAGING=aar |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<manifest package="com.trello.rxlifecycle.kotlin" /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.trello.rxlifecycle.kotlin | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should have copyright at top of file. |
||
|
||
import android.view.View | ||
import com.trello.rxlifecycle.ActivityLifecycleProvider | ||
import com.trello.rxlifecycle.FragmentLifecycleProvider | ||
import com.trello.rxlifecycle.RxLifecycle | ||
import rx.Observable | ||
|
||
fun <T> Observable<T>.bind(activity: ActivityLifecycleProvider): Observable<T> = this.compose<T>(activity.bindToLifecycle<T>()) | ||
|
||
fun <T> Observable<T>.bind(fragment: FragmentLifecycleProvider): Observable<T> = this.compose<T>(fragment.bindToLifecycle<T>()) | ||
|
||
fun <T> Observable<T>.bind(view: View): Observable<T> = this.compose<T>(RxLifecycle.bindView(view)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be both |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
include ':rxlifecycle' | ||
include ':rxlifecycle', ':rxlifecycle-kotlin' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this be on a newline to match the rest of it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. of course! |
||
include ':rxlifecycle-components' | ||
include ':rxlifecycle-navi' | ||
include ':rxlifecycle-sample' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment seems unnecessary.