Skip to content

Commit 674b6be

Browse files
hoeggiflorina-muntenescu
authored andcommittedDec 1, 2017
Remove usage of internal rxjava classes (#244)
* remove usage of internal rxjava classes * remove unneeded parens from kotlin sample
1 parent 1532c56 commit 674b6be

File tree

2 files changed

+3
-10
lines changed
  • BasicRxJavaSample/app/src/main/java/com/example/android/observability/ui
  • BasicRxJavaSampleKotlin/app/src/main/java/com/example/android/observability/ui

2 files changed

+3
-10
lines changed
 

‎BasicRxJavaSample/app/src/main/java/com/example/android/observability/ui/UserViewModel.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,10 @@
1717
package com.example.android.observability.ui;
1818

1919
import android.arch.lifecycle.ViewModel;
20-
2120
import com.example.android.observability.UserDataSource;
2221
import com.example.android.observability.persistence.User;
23-
2422
import io.reactivex.Completable;
2523
import io.reactivex.Flowable;
26-
import io.reactivex.functions.Action;
27-
import io.reactivex.functions.Function;
28-
import io.reactivex.internal.operators.completable.CompletableFromAction;
2924

3025
/**
3126
* View Model for the {@link UserActivity}
@@ -62,7 +57,7 @@ public Flowable<String> getUserName() {
6257
* @return a {@link Completable} that completes when the user name is updated
6358
*/
6459
public Completable updateUserName(final String userName) {
65-
return new CompletableFromAction(() -> {
60+
return Completable.fromAction(() -> {
6661
// if there's no use, create a new user.
6762
// if we already have a user, then, since the user object is immutable,
6863
// create a new user, with the id of the previous user and the updated user name.

‎BasicRxJavaSampleKotlin/app/src/main/java/com/example/android/observability/ui/UserViewModel.kt

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import com.example.android.observability.persistence.User
2121
import com.example.android.observability.persistence.UserDao
2222
import io.reactivex.Completable
2323
import io.reactivex.Flowable
24-
import io.reactivex.functions.Action
25-
import io.reactivex.internal.operators.completable.CompletableFromAction
2624

2725
/**
2826
* View Model for the [UserActivity]
@@ -47,10 +45,10 @@ class UserViewModel(private val dataSource: UserDao) : ViewModel() {
4745
* @return a [Completable] that completes when the user name is updated
4846
*/
4947
fun updateUserName(userName: String): Completable {
50-
return CompletableFromAction(Action {
48+
return Completable.fromAction {
5149
val user = User(USER_ID, userName)
5250
dataSource.insertUser(user)
53-
})
51+
}
5452
}
5553

5654
companion object {

0 commit comments

Comments
 (0)
Please sign in to comment.