Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lenguyenthanh/rxarrow

RxJava extensions for Arrow's Data Types
https://github.com/lenguyenthanh/rxarrow

arrow arrow-kt functional-programming kotlin reactive-programming rxjava rxjava2

Last synced: about 1 month ago
JSON representation

RxJava extensions for Arrow's Data Types

Awesome Lists containing this project

README

        

# RxArrow [![](https://jitpack.io/v/lenguyenthanh/RxArrow.svg)](https://jitpack.io/#lenguyenthanh/RxArrow)

RxArrow is a collection of RxJava extensions and typealiases [Arrow's Data Types](https://arrow-kt.io).

## Table of Contents

+ [Why Z](#z)
+ [Usage](#usage)
+ [Setup](#setup)
+ [Compatibility](#compatibility)
+ [Contributing](#contributing)
+ [License](/LICENSE)

## Why `Z`

I use `Z` as a postfix for all typealiases because I was influenced by [ZIO](https://zio.dev).

## Usage

### [Observable> aka ObservableZ](https://github.com/lenguyenthanh/RxArrow/blob/master/src/main/kotlin/com/lenguyenthanh/rxarrow/ObservableZ.kt)

`ObservableZ` is a type alias for `Observable>`. It has a convenient extension functions to make life easier when working with `Observable>`.

```Kotlin

Observable.just("error".left(), 23.right()) // Left(error), Right(24): ObservableZ
.mapZ { it + 2 } // Left("error"), Right(25): ObservableZ
.mapLeft { it.reversed() } // Left("rorre"), Right(25): ObservableZ
.mapLeft { SomethingWentWrong } // Left(SomethingWentWrong), Right(25): ObservableZ
.flatMapZ { Observable.just(it * it) } // Left(SomethingWentWrong), Right(625): ObservableZ
.flatMapSingleEither { divide(it, 0) } // Left(SomethingWentWrong), Left(DevidedByZero): ObservableZ
.subscribe { either -> println("$either") }
```

### [Single> aka SingleZ](https://github.com/lenguyenthanh/RxArrow/blob/master/src/main/kotlin/com/lenguyenthanh/rxarrow/SingleZ.kt)

Similar to `ObservableZ`

### [Maybe> aka MaybeZ](https://github.com/lenguyenthanh/RxArrow/blob/master/src/main/kotlin/com/lenguyenthanh/rxarrow/MaybeZ.kt)

Similar to `ObservableZ`

## Setup

You can get `RxArrow` by using [Jitpack](https://jitpack.io/#lenguyenthanh/RxArrow/).

```Gradle
repositories {
jcenter()
maven { url 'https://jitpack.io' }
}

implementation "io.arrow-kt:arrow-core:$arrow_version"
implementation "com.github.lenguyenthanh:RxArrow:$rxarrow"
```

## Compatibility

Supports RxJava2 and Arrow version `0.13.2`.

## Contributing

Any bug reports, feature requests, questions and pull requests are very welcome.