3

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
Community
  • 1
  • 1
Zappel
  • 1,612
  • 1
  • 22
  • 37
  • I don't fully understand the linked libraries (I'm not an iOS/Swift dev) but it somewhat resembles to the [RxJavaComputationExpressions](https://github.com/ReactiveX/RxJavaComputationExpressions) ([in v2](https://github.com/akarnokd/RxJava2Extensions#asynchronous-jumpstarting-a-sequence)) or Android's own `AsyncTask`. I'd suggest rethinking what you want to achieve and use straightforward RxJava constructs though. – akarnokd Feb 28 '18 at 14:25
  • Closest thing https://github.com/ReactiveX/RxAndroid – Nongthonbam Tonthoi Feb 28 '18 at 14:28
  • Are you thinking of a Java [`Callable`](https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Callable.html)? You include some work to be done inside the `call` method and you can submit it to an `Executor` to get a `Future` or make it into an Observable with `Observable.fromCallable()` – David Rawson Mar 03 '18 at 05:37

1 Answers1

0

We ended up porting the iOS version ourselves.

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

Zappel
  • 1,612
  • 1
  • 22
  • 37