Search code examples
androidiosrx-javarx-swiftrx-kotlin

RxSwift like Actions for Android


I was first introduced to reactive programming with ReactiveCocoa several years ago. In there they had the notion on RACCommands, which was carried over to RxSwift with the extension library Action.

As stated on their GitHub page:

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.

In my experience it is an absolutely indispensable tool in the reactive programming toolbox when doing robust, reactive iOS development.


Now we would like to carry this over to Android app as well. But after countless hours of research I have not been able to find a corresponding component for either RxJava or RxKotlin.

The implementation in Swift is relatively straight forward, so we could just port it, but I'd first like to hear if:

  1. This really does not exists, and if so
  2. Is there an Android specific reason for this to not exist, i.e. a reason not to port it

Solution

  • We ended up porting the iOS version ourselves.

    It's open source and can be found here: https://github.com/tonsser/kaction