All Projects â†’ AdevintaSpain â†’ RxPager

AdevintaSpain / RxPager

Licence: other
RxPager is an Android library that helps handling paginated results in a reactive way

Programming Languages

java
68154 projects - #9 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to RxPager

RxActivityResults
Android onActivityResult wrapper powered by RxJava
Stars: ✭ 14 (-75%)
Mutual labels:  reactivex, rxjava2
Protein
💊 Protein is an IntelliJ Plugin to generate Kotlin code for Retrofit 2 and RxJava 2 based on a Swagger definition
Stars: ✭ 273 (+387.5%)
Mutual labels:  reactivex, rxjava2
Rxdownloader
- Reactive Extension Library for Android to download files
Stars: ✭ 40 (-28.57%)
Mutual labels:  reactivex, rxjava2
Experiments
A repository to capture simple code experiments
Stars: ✭ 140 (+150%)
Mutual labels:  reactivex
Awesome Reactive Programming
A repository for sharing all the resources available on Reactive Programming and Reactive Systems
Stars: ✭ 163 (+191.07%)
Mutual labels:  reactivex
Camelotia
Cross-platform .NET sample GUI app for cloud file management. Built with ReactiveUI, AvaloniaUI, Universal Windows Platform, Xamarin Forms, and WPF, runs on Windows, Linux, Mac and Android.
Stars: ✭ 221 (+294.64%)
Mutual labels:  reactivex
Android-Starter-Kit
This is up-to-date android studio project for native android application, that is using modern tools and libraries.
Stars: ✭ 16 (-71.43%)
Mutual labels:  rxjava2
Reactiveui.samples
This repository contains ReactiveUI samples.
Stars: ✭ 127 (+126.79%)
Mutual labels:  reactivex
BringMyOwnBeer-
PunkAPI(BrewDog) 을 이용한 RxSwift-MVVM 예제 (Naver Tech Concert)
Stars: ✭ 80 (+42.86%)
Mutual labels:  reactivex
Reactive Examples
Samples App using the Reactive Extensions and Reactive UI
Stars: ✭ 203 (+262.5%)
Mutual labels:  reactivex
Rxkingfisher
Reactive extension for the Kingfisher image downloading and caching library
Stars: ✭ 190 (+239.29%)
Mutual labels:  reactivex
Newbe.claptrap
This is a frameworks with reactive, event sourcing and Actor pattern as basic theories. On top of this, developers can create "distributed", "scale out", and "easy to test" application more simply. Claptrap and it`s Minions is on the way.
Stars: ✭ 163 (+191.07%)
Mutual labels:  reactivex
spotify-song-recommender
A Spotify song recommendation engine built with the power of graph analytics.
Stars: ✭ 34 (-39.29%)
Mutual labels:  pager
Monix
Asynchronous, Reactive Programming for Scala and Scala.js.
Stars: ✭ 1,819 (+3148.21%)
Mutual labels:  reactivex
autopagerize
Infiniscroll on web pages using a large database of rules. A fully reworked fork of the original extension.
Stars: ✭ 55 (-1.79%)
Mutual labels:  pager
Ayanami
🍭 A better way to react with state
Stars: ✭ 129 (+130.36%)
Mutual labels:  reactivex
flutter-form-with-validation-BLOC
This form and validation functions are created by using the BLOC pattern with RxDart instead of using StatefulWidget
Stars: ✭ 63 (+12.5%)
Mutual labels:  reactivex
Rxkotlinfx
Kotlin extensions to the RxJavaFX framework
Stars: ✭ 177 (+216.07%)
Mutual labels:  reactivex
Deepspeech Server
A testing server for a speech to text service based on mozilla deepspeech
Stars: ✭ 176 (+214.29%)
Mutual labels:  reactivex
Rxcpp
Reactive Extensions for C++
Stars: ✭ 2,513 (+4387.5%)
Mutual labels:  reactivex

Download

RxPager

RxPager is an Android library that helps handling paginated results in a reactive way

Is based on this gist from @mttkay

##Download Grab the latest version from jCenter:

dependencies {
  compile 'com.schibstedspain.android:rxpager:2.0.0'
}

##Creation Pager pager = new Pager(initialPageToken, (oldPageToken, pageResult) -> pageResult.getNextPageToken(), token -> getPage(token) )

or if you want to use offset instead of token:

Pager pager = new Pager(0, (offset, pageResult) -> offset + pageResult.size(), offset -> getPageWithOffset(offset)

The first 2 parameter are like rxjava scan.

The third parameter is a Func1 wich returns an Observable, is your repository/datasource call, and you are responsible to set subscribeOn() to this observable if you want it to be executed out of the main thread.

##Usage To get the content, just subscribe to: pager.getPageObservable() It will call onNext with the first page, and will continue giving to you the next pages when you call pager.next() and complete when the returned page have nullas nextPageToken

To know if its loading, there is another observable available: pager.getIsLoadingObservable() and last, there is pager.hasNext() wich returns a Boolean.

##Common data types There is available a POJO called: TokenPage

TokenPage(String nextPageToken, List<ITEM> results) being ITEM the type of your elements in the list.

##Example This library includes tests to describe the behavior and also a Sample, in order to show you how it works I'll take the code from the Sample MainActivity.

public class MainActivity extends AppCompatActivity {
  private final CompositeSubscription compositeSubscription = new CompositeSubscription();

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    DataSource dataSource = new DataSource();
    Pager<TokenPage<String>, String> pager = new Pager<>(
        DataSource.FIRST_PAGE_TOKEN,
        (oldToken, tokenPage) -> tokenPage.getNextPageToken(),
        dataSource::getPage);

    Adapter adapter = new Adapter();
    MainActivityBinding binding = DataBindingUtil.setContentView(this, R.layout.main_activity);
    binding.list.setLayoutManager(new LinearLayoutManager(this));
    binding.list.setAdapter(adapter);
    binding.list.addOnScrollListener(new OnScrollToBottomListener(pager::next));

    Subscription pageSubscription = pager.getPageObservable()
        .map(TokenPage::getResults)
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(adapter::addItems);
    compositeSubscription.add(pageSubscription);

    Subscription loadingSubscription = pager.getIsLoadingObservable()
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(adapter::setIsLoading);
    compositeSubscription.add(loadingSubscription);
  }

  @Override
  protected void onDestroy() {
    compositeSubscription.clear();
    super.onDestroy();
  }
}

License

Copyright 2016 Schibsted Classified Media Spain S.L.


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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].