Coder Social home page Coder Social logo

rxjava-operators's Introduction

Rxjava Operators

JitPack

Usage

  • OperatorFlatList
  • OperatorFrequency
  • OperatorGroupByGroup
  • OperatorReverse
  • OperatorShuffle
  • OperatorToReversedList
  • OperatorToShuffledList

OperatorToReversedList/OperatorReverse

Before:

Observable.range(1, 10).toList().doOnNext(list -> Collections.reverse(list))
    .subscribe(System.out::println);
// [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

After:

Observable.range(1, 10).toList().lift(new OperatorToReversedList())
    .subscribe(System.out::println);
// [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

or

Observable.range(1, 10).lift(new OperatorToReverse())
    .subscribe(System.out::println);
// 10
// 9
// 8
// 7
// 6
// 5
// 4
// 3
// 2
// 1

OperatorFrequency

Before:

Observable.range(1, 10).zipWith(Observable.interval(1, TimeUnit.SECONDS), (i, t) -> i)
    .subscribe(i -> System.out.println(i + ": " + System.currentTimeMillis()));
// 1: 1428053481338
// 2: 1428053482339
// 3: 1428053483338
// 4: 1428053474339
// 5: 1428053475338
// 6: 1428053476338
// 7: 1428053477338
// 8: 1428053478338
// 9: 1428053479338
// 10: 1428053480338

After:

Observable.range(1, 10).lift(OperatorFrequency.create(1, TimeUnit.SECONDS))
    .subscribe(i -> System.out.println(i + ": " + System.currentTimeMillis()));

OperatorFlatList

Before:

Observable.range(1, 10).toList().flatMap(Observable::from)
    .subscribe(System.out::println);

After:

Observable.range(1, 10).toList().lift(new OperatorFlatList())
    .subscribe(System.out::println);

OperatorToShuffledList/OperatorShuffle

Observable.range(1, 10).toList().lift(new OperatorToShuffledList())
    .subscribe(System.out::println);

or

Observable.range(1, 10).lift(new OperatorShuffle())
    .subscribe(System.out::println);

Installation

repositories {
    jcenter()
    maven { url "https://jitpack.io" }
}

dependencies {
    compile 'com.github.yongjhih:RxJava-Operators:-SNAPSHOT'
}

Test

./gradlew test

License

Apache 2.0 2014 8tory, Inc.

rxjava-operators's People

Contributors

yongjhih avatar wendly avatar

Stargazers

Johann Chang avatar  avatar chonamdoo avatar

Watchers

 avatar James Cloos avatar  avatar

rxjava-operators's Issues

Support least() for filter

or support filter(Observable<Boolean>) to be able to:

filter(obs -> obs.count().filter(i -> i > 3))

The workaround maybe:

obs.flatMap(post -> post.comments().skip(1).isEmpty().flatMap(b -> b ? Observabe.empty() : Observable.just(post)));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.