RxSwift 喜欢 Android 的操作

RxSwift like Actions for Android

几年前,我第一次接触到 ReactiveCocoa 的反应式编程。在那里他们有了关于 RACCommands 的概念,它被带到 RxSwift 和扩展库 Action.

如他们的 GitHub 页面所述:

An action is a way to say "hey, later I'll need you to subscribe to this thing."

Actions accept a workFactory: a closure that takes some input and produces an observable. When execute() is called, it passes its parameter to this closure and subscribes to the work.

  • Can only be executed while "enabled" (true if unspecified).
  • Only execute one thing at a time.
  • Aggregates next/error events across individual executions.

根据我的经验,在进行稳健的反应式 iOS 开发时,它绝对是反应式编程工具箱中 必不可少的 工具。


现在我们想把它也带到 Android 应用程序中。但是经过无数小时的研究,我一直没能为 RxJavaRxKotlin.

找到相应的组件

Swift 中的实现相对简单,所以我们可以 移植它,但我首先想听听是否:

  1. 这真的不存在,如果有的话
  2. 是否有Android不存在的具体原因,即移植它的原因

我们最终自己移植了 iOS 版本。

它是开源的,可以在这里找到:https://github.com/tonsser/kaction