当前位置: 首页 > 软件库 > 手机/移动开发 > >

RxJava2-Android-Samples

授权协议 Apache-2.0 License
开发语言 Java
所属分类 手机/移动开发
软件类型 开源软件
地区 不详
投 递 者 孟俊发
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Learning RxJava 2 for Android by example

Open Source Love

Take the MindOrks Android Online Course and Learn RxJava

How to use RxJava 2 in Android Application

How to migrate from RxJava 1.0 to RxJava 2.0

How to use RxJava 3 in Android Application Check here

Kotlin-Coroutines-Android-Examples - Check here

This project is for :

  • who is migrating to RxJava 2
  • or just started with RxJava.

Just Build the project and start learning RxJava by examples.

RxJava 2.0 has been completely rewritten from scratch on top of the Reactive-Streams specification. The specification itself has evolved out of RxJava 1.x and provides a common baseline for reactive systems and libraries.

Because Reactive-Streams has a different architecture, it mandates changes to some well known RxJava types.

Migration From RxJava 1.0 to RxJava 2.0

To allow having RxJava 1 and RxJava 2 side-by-side, RxJava 2 is under the maven coordinatesio.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 RxJava 2.0 Library in your application

Add this in your build.gradle

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

If you are using RxAndroid also, then add the following

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

RxJava 2 Examples present in this sample project

  • RxJava 2.0 Example using CompositeDisposable as CompositeSubscription and Subscription havebeen removed.

  • RxJava 2 Example using Flowable.

  • RxJava 2 Example using SingleObserver, CompletableObserver.

  • RxJava 2 Example using RxJava2 operators such as map, zip, take, reduce, flatMap, filter, buffer, skip, merge, concat, replay, and much more:

  • RxJava 2 Android Samples using Function as Func1 has been removed.

  • RxJava 2 Android Samples using BiFunction as Func2 has been removed.

  • And many others android examples

Quick Look on few changes done in RxJava2 over RxJava1

RxJava1 -> RxJava2

  • onCompleted -> onComplete - without the trailing d
  • Func1 -> Function
  • Func2 -> BiFunction
  • CompositeSubscription -> CompositeDisposable
  • limit operator has been removed - Use take in RxJava2
  • and much more.

Operators :

  • 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
  • Filter -> emit only those items from an Observable that pass a predicate test
  • FlatMap -> transform the items emitted by an Observable into Observables, then flatten the emissions from those into a single Observable
  • Take -> emit only the first n items emitted by an Observable
  • Reduce -> apply a function to each item emitted by an Observable, sequentially, and emit the final value
  • Skip -> suppress the first n items emitted by an Observable
  • Buffer -> periodically gather items emitted by an Observable into bundles and emit these bundles rather than emitting the items one at a time
  • Concat -> emit the emissions from two or more Observables without interleaving them
  • Replay -> ensure that all observers see the same sequence of emitted items, even if they subscribe after the Observable has begun emitting items
  • Merge -> combine multiple Observables into one by merging their emissions
  • SwitchMap -> transform the items emitted by an Observable into Observables, and mirror those items emitted by the most-recently transformed Observable

Highlights of the examples :

TODO

  • Many examples are to be added

Find this project useful ? ❤️

  • Support it by clicking the button on the upper right of this page. ✌️

Check out an awesome MVP architecture based project which uses RxJava2, Dagger2.

Check out an awesome Kotlin MVP architecture based project which uses RxJava2, Dagger2.

Check out an awesome library for fast and simple networking in Android.

Another awesome library for debugging databases and shared preferences.

Learn to build a ride-sharing Android app like Uber, Lyft.

Check out Mindorks awesome open source projects here

Contact - Let's become friend

License

   Copyright (C) 2016 Amit Shekhar
   Copyright (C) 2011 Android Open Source Project

   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.

Contributing to RxJava 2 Android Samples

Just make pull request. You are in!

  • 最近工作不那么忙,计划重新搭建一个MVP架构!基于Rxjava2-Rxandroid首先掌握RxJava2的使用的方式! 此文章是根据老外amitshekhariitbhu的RxJava2-Android-SamplesDemo 改装而成,是个翻译版本,足够应付对RxJava2的全部姿势! GitHub地址: RxJava2-Android-Samples Map - >通过对每个项应用函数来变换

  • 定义 RxJava 提供一套异步编程的 API,这套 API 是基于观察者模式的,而且是链式调用的,所以使用 RxJava 编写的代码的逻辑会非常简洁。 相关基础 观察者模式 当对象间存在一对多关系时,则使用观察者模式(Observer Pattern)。比如,当一个对象被修改时,则会自动通知依赖它的对象。观察者模式属于行为型模式。应用场景示例:微信公众号的订阅功能。 观察者模式简单实现 参考:

  •         从去年(2015)10月份左右接触到RxJava到今(2016.03)也有近半个年,从一开始的Rx风格的蒙圈代码到现在自己项目中必不可少的Lib,多多少少积累下来一些经验,再加上周边小伙伴不时的问这个依赖(RxJava)是什么?这代码什么意思?RxJava是什么?能做什么?很牛B吗?- -!有时候真的问的人无言以对。              1、Rxjava是什么(响应式编程)

 相关资料
  • 何时调用subscribeWith方法而不是普通的Subscribe?用例是什么? VS 谢谢你 根据文档,这两个实例都返回一次性的SingleObserver实例: 其中ConsumerSingleObserver类实现SingleObserver和Disable。

  • 我做错了什么?我如何将结果与可观察的结果结合起来?最好不是用Lamda符号。 我查看的其他资源:-android rxjava2/retrofit2链接调用与分页令牌

  • 我正在android中学习RxJava2。谁能解释一下,我们如何使用RxJava2将数据插入SQLiteDatabase。这里是我试图使用的代码示例,但它将数据插入数据库六次; //OnClick(单击) //可观察 //观察员 //添加方法

  • 可观察的如下所示。

  • 我使用REST API查询Person对象列表。最大限制是100人响应。我需要把所有的人都叫来,总数不详。第一个响应中有一个名为“next”的字段,包含下一页的url。我需要使用rxjava/rxandroid和referfit链接这些调用,直到最后一个响应有一个空的“next”字段。由于“Next”字段包含分页url,所有后续调用都将具有与第一个不同的url。做这件事最方便的方法是什么?

  • 我有一个自定义对象列表(