Giter VIP home page Giter VIP logo

architectak / rxkotlin-rxjava2-android-samples Goto Github PK

View Code? Open in Web Editor NEW
69.0 5.0 24.0 765 KB

Learning RxKotlin2 for Android by Examples - Migration From RxKotlin1/RxJava1 to RxKotlin2/RxJava2 - How to use RxKotlin 2 in Android - RxLogin using RxBinding - Pagination using RxKotlin

Kotlin 99.48% Java 0.52%
rxkotlin rxkotlin-android rxkotlinfx rxandroid2 tutorial rxandroid2-sample kotlin emits rxjava rx-java2

rxkotlin-rxjava2-android-samples's Introduction

RxKotlinOperators

Learn RxKotlin with simple coding examples

GitHub stars | GitHub followers

Migration from RxKotlin 1.0 to RxKotlin 2.0

To allow having RxKotlin 1 and RxKotlin 2 side-by-side, RxKotlin 2 is under the maven coordinates io.reactivex.rxjava2:rxjava:2.x.y and classes are accessible below io.reactivex. Users switching from 1.x to 2.x have to re-organize their imports, but carefully.

Using RxKotlin 2.0 Library in your application

Add this in your build.gradle

compile 'io.reactivex.rxjava2:rxjava:2.1.1'

If you are using RxAndroid also, then add the following

compile 'io.reactivex.rxjava2:rxandroid:2.0.1'

Quick Look on few changes done in RxKotlin2 over RxKotlin1

RxJava1/RxKotlin1 -> RxJava2/RxKotlin2

  • onCompleted -> onComplete - without the trailing d
  • Func1 -> Function
  • Func2 -> BiFunction
  • CompositeSubscription -> CompositeDisposable
  • limit operator has been removed - Use take in RxKotlin2

....... and so on

RxOperators :

  • map() -> Transform the items emitted by an Observable by applying a function to each item

  • zip() -> Combine the emissions of multiple Observables together via a specified function and emit single items for each combination based on the results of this function

  • take() -> Emit only the first n items emitted by an Observable

  • timer() -> Create an Observable that emits a particular item after a given delay

  • flatMap() -> Transform the items emitted by an Observable into Observables, then flatten the emissions from those into a single Observable

  • interval() -> Create an Observable that emits a sequence of integers spaced by a given time interval

  • debounce() -> Only emit an item from an Observable if a particular time span has passed without it emitting another item

  • Single Observer -> A Single is something like an Observable, but instead of emitting a series of values — anywhere from none at all to an infinite number — it always either emits one value or an error notification.

  • reduce() -> Apply a function to each item emitted by an Observable, sequentially, and emit the final value

  • buffer() -> Periodically gather items emitted by an Observable into bundles and emit these bundles rather than emitting the items one at a time

  • filter() -> Emit only those items from an Observable that pass a predicate test

  • skip() -> Suppress the first n items emitted by an Observable

  • scan() -> Apply a function to each item emitted by an Observable, sequentially, and emit each successive value

  • replay() -> Ensure that all observers see the same sequence of emitted items, even if they subscribe after the Observable has begun emitting items

  • concat() -> Emit the emissions from two or more Observables without interleaving them

  • merge() -> Combine multiple Observables into one by merging their emissions

  • defer() -> The Defer operator waits until an observer subscribes to it, and then it generates an Observable, typically with an Observable factory function. It does this afresh for each subscriber, so although each subscriber may think it is subscribing to the same Observable, in fact each subscriber gets its own individual sequence.

  • distinct() -> Suppress duplicate items emitted by an Observable

  • Replay Subject -> Replays events (in a configurable bounded or unbounded manner) to current and late Observers.

  • Publish Subject -> Subject that, once an Observer has subscribed, emits all subsequently observed items to the subscriber

  • Behaviour Subject -> Subject that emits the most recent item it has observed and all subsequent observed items to each subscribed Observer.

  • Aync Subject -> A Subject that emits the very last value followed by a completion event or the received error to Observers.

  • Throttle First -> Emit the first items emitted by an Observable within periodic time intervals

  • amb() -> Given two or more source Observables, emits all of the items from the first of these Observables to emit an item

  • Catch -> Recover from an onError notification by continuing the sequence without error

  • Retry -> If a source Observable emits an error, resubscribe to it in the hopes that it will complete without error

  • Coming More

TODO

Adding more operator examples

Highlights :

RxBinding

Rx is powerful because we can compose transformations. What that means is that we can have reusable, safe and more functional code that simply plugs into your code.

As an example let’s say we’re making a login screen with an email and a password…

Consider the following rules that we want for our email addresses

  • Length should be greater than 6
  • Should have a correct email pattern
  • Let the user know if any of the above fails
  • On each key stroke, verify

Highlights :

Pagination And Lazy loading using RxKotlin

Highlights :

Contact - Let's connect to learn together

License

Copyright 2017 Ankit Kumar

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.

rxkotlin-rxjava2-android-samples's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

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.