GithubHelp home page GithubHelp logo

felixzhang00 / rxjavasamples Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rengwuxian/rxjavasamples

0.0 2.0 0.0 4.5 MB

RxJava 2 和 Retrofit 结合使用的几个最常见使用方式举例

Java 100.00%

rxjavasamples's Introduction

样例代码已正式切换到基于 RxJava 2

需要旧版 RxJava 1 代码的点这里

项目介绍

RxJava 2 和 Retrofit 结合使用的几个最常见使用方式举例。

  1. 基本使用

实现最基本的网络请求和结果处理。 screenshot_1

  1. 转换(map)

把返回的数据转换成更方便处理的格式再交给 Observer。 screenshot_2

  1. 压合(zip)

将不同接口并行请求获取到的数据糅合在一起后再处理。 screenshot_3

  1. 一次性 token

需要先请求 token 再访问的接口,使用 flatMap() 将 token 的请求和实际数据的请求连贯地串起来,而不必写嵌套的 Callback 结构。 screenshot_4

  1. 非一次性 token

对于非一次性的 token (即可重复使用的 token),在获取 token 后将它保存起来反复使用,并通过 retryWhen() 实现 token 失效时的自动重新获取,将 token 获取的流程彻底透明化,简化开发流程。 screenshot_5

  1. 缓存

使用 BehaviorSubject 缓存数据。 screenshot_6

apk 下载

RxJavaSamples_2.0.apk

rxjavasamples's People

Contributors

rengwuxian avatar devinfu avatar troyliu0105 avatar viizki avatar dearzhai avatar

Watchers

James Cloos avatar Fei Zhang 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.