Commit 32e47b10 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update RealmUserRepository.java

parent da03132a
...@@ -5,6 +5,8 @@ import android.support.v4.util.Pair; ...@@ -5,6 +5,8 @@ import android.support.v4.util.Pair;
import com.hadisatrio.optional.Optional; import com.hadisatrio.optional.Optional;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -27,6 +29,21 @@ public class RealmUserRepository extends RealmRepository implements UserReposito ...@@ -27,6 +29,21 @@ public class RealmUserRepository extends RealmRepository implements UserReposito
this.hostname = hostname; this.hostname = hostname;
} }
@Override
public Flowable<List<User>> getAll() {
return Flowable.defer(() -> Flowable.using(
() -> new Pair<>(RealmStore.getRealm(hostname), Looper.myLooper()),
pair -> RxJavaInterop.toV2Flowable(
pair.first.where(RealmUser.class)
.findAll()
.asObservable()),
pair -> close(pair.first, pair.second))
.unsubscribeOn(AndroidSchedulers.from(Looper.myLooper()))
.filter(roomSubscriptions -> roomSubscriptions != null && roomSubscriptions.isLoaded()
&& roomSubscriptions.isValid())
.map(this::toList));
}
@Override @Override
public Flowable<Optional<User>> getCurrent() { public Flowable<Optional<User>> getCurrent() {
return Flowable.defer(() -> return Flowable.defer(() ->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment