• Stars
    star
    169
  • Rank 224,453 (Top 5 %)
  • Language
    HTML
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

DEPRECATED data loading solution for android to load data with no memory leaks, no boiler-plate, and no method count bloat

Deprecated

The newer live data offers a better solution to this problem. If you're interested in using rx with live data, you can checkout the live data from reactive streams api

Download

RxLoader

compose() your Observables and Singles into ones that load data that's cached across activity orientation changes without leaking your Activity and without you having to worry about unsubscribing.

RxLoader accomplishes this by building on top of Android Loaders, so the library is super lightweight (only defines 47 methods).

There's a lot of data loading solutions already for Android. I detail why I felt we needed another one here

Code

Github repo is here. Note that it contains some rough sample code.

Javadoc

Here

Basic Usage

build.gradle

dependencies {
  compile 'com.philosophicalhacker.rxloader:rxloader:0.4.0'
}  

FooActivity

@Override
protected void onCreate(Bundle savedInstanceState) {
    final RxLoader rxLoader = new RxLoader(this, getSupportLoaderManager());
    storyApiService
        .getAskStories()
        .compose(rxLoader.<List<Integer>>makeSingleTransformer())
        .subscribe(new Consumer<List<Integer>>() {
          @Override public void accept(List<Integer> integers) {
            Log.d(TAG, "call() called with: integers = [" + integers + "]");
          }
        });
}

Notice that you don't have worry about calling subscribeOn or observeOn either. That's handled by RxLoader.

License

Copyright 2017 Kevin Matthew Dupree

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.