• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ArchitectAK/RxKotlin-RxJava2-Android-Samples: Learning RxKotlin2 for Android by ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

ArchitectAK/RxKotlin-RxJava2-Android-Samples

开源软件地址(OpenSource Url):

https://github.com/ArchitectAK/RxKotlin-RxJava2-Android-Samples

开源编程语言(OpenSource Language):

Kotlin 99.5%

开源软件介绍(OpenSource 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.



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap