Skip to content

Commit

Permalink
Merge pull request #11 from noheltcj/v0.1.0
Browse files Browse the repository at this point in the history
Release v0.1.0
  • Loading branch information
noheltcj authored Sep 23, 2018
2 parents 86878f7 + 78180a7 commit 987f7cd
Show file tree
Hide file tree
Showing 54 changed files with 2,481 additions and 166 deletions.
97 changes: 96 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,97 @@
# RxCommon
A multi-platform partial implementation of ReactiveX.
A multi-platform (Native, JVM, iOS, macOS, and JS) implementation of ReactiveX.

## Documentation
Please refer to <https://reactivex.io> for documentation.

While this is currently only a partial implementation, I'm doing my best
to follow the spec as closely as possible.

### Operators
More operators are coming quickly, but not all have been implemented.

Currently supported operators:
* [Map](http://reactivex.io/documentation/operators/map.html)
* [FlatMap](http://reactivex.io/documentation/operators/flatmap.html)
* SwitchMap (non-interleaving variant of [FlatMap](http://reactivex.io/documentation/operators/flatmap.html))
* [CombineLatest](http://reactivex.io/documentation/operators/combinelatest.html)

## Installing
There are several places requiring imports to utilize this library.

### Common Module
```groovy
implementation "com.noheltcj:rx-common:0.1.0"
```

### JVM Module
```groovy
implementation "com.noheltcj:rx-common-jvm:0.1.0"
```

### JavaScript Module
```groovy
implementation "com.noheltcj:rx-common-js:0.1.0"
```

### Native Module
Slightly more complicated. See the [Native Distribution Limitation](#native-library-distribution)

## Temporary Limitations
As this is a new project with only one contributor, I haven't had time
to implement many of the things we've come to expect from a complete Rx
implementation.

### Native Library Distribution
I haven't had time to fully work out distribution via maven central for
the native kotlin library in kotlin/native projects.

_You can find the pre-built kotlin libraries zipped in the release tag for each
version._

To install this and successfully produce a framework which can be
distributed for use in XCode projects, you'll need to manually install
the .klib files for your target architectures.

For example, the following gradle script looks for the files in in the
lib directory of the kotlin/native project.

```groovy
apply plugin: 'konan'
konanArtifacts {
framework('Example', targets: ['ios_x64', 'ios_arm64']) {
extraOpts '-module_name', 'EX'
enableMultiplatform true
target('ios_x64') {
libraries {
useRepo 'lib/ios_x64'
noStdLib true // Avoids linker issues
klib 'RxCommon'
}
}
target('ios_arm64') {
libraries {
useRepo 'lib/ios_arm64'
noStdLib true
klib 'RxCommon'
}
}
}
}
```

### Objective-C Generics
Objective-c only has partial generics support, so we lose a bit of
information when this library is imported as a framework in XCode.

### Concurrency
There is absolutely no thread safety or scheduling in the library yet,
but it's on the to-do list. In the meantime, it's best to keep any
application state and logic that utilizes this library on one thread.
This doesn't mean you can't still operate on different threads, just
transfer any data back to the designated thread. I personally use the
existing platform specific implementations of Rx (RxSwift, RxJava, etc)
to do this.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
buildscript {
ext {
project_group_id = 'com.noheltcj'
project_version = '0.0.2'
kotlin_version = '1.2.60'
project_version = '0.1.0'
kotlin_version = '1.2.70'
upload_artifacts = System.getenv("uploadArtifacts") == "true"
}

Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'kotlin-platform-common' version '1.2.60'
id 'kotlin-platform-common' version '1.2.70'
}

group = project_group_id
Expand Down
15 changes: 0 additions & 15 deletions common/src/main/kotlin/com/noheltcj/rxcommon/Channel.kt

This file was deleted.

5 changes: 0 additions & 5 deletions common/src/main/kotlin/com/noheltcj/rxcommon/Channels.kt

This file was deleted.

45 changes: 0 additions & 45 deletions common/src/main/kotlin/com/noheltcj/rxcommon/DataRelay.kt

This file was deleted.

5 changes: 0 additions & 5 deletions common/src/main/kotlin/com/noheltcj/rxcommon/Disposable.kt

This file was deleted.

17 changes: 17 additions & 0 deletions common/src/main/kotlin/com/noheltcj/rxcommon/Source.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.noheltcj.rxcommon

import com.noheltcj.rxcommon.disposables.Disposable
import com.noheltcj.rxcommon.observers.Observer
import com.noheltcj.rxcommon.operators.CombineLatest
import com.noheltcj.rxcommon.operators.FlatMap
import com.noheltcj.rxcommon.operators.MapOperator
import com.noheltcj.rxcommon.operators.SwitchMap

interface Source<E> {
fun subscribe(observer: Observer<E>) : Disposable

fun <O, R> combineLatest(otherSource: Source<O>, transform: (E, O) -> R): Source<R> = CombineLatest(this, otherSource, transform)
fun <R> map(transform: (E) -> R): Source<R> = MapOperator(this, transform)
fun <R> flatMap(resolveAdditionalSource: (E) -> Source<R>) : Source<R> = FlatMap(this, resolveAdditionalSource)
fun <R> switchMap(resolveNewSource: (E) -> Source<R>) : Source<R> = SwitchMap(this, resolveNewSource)
}
10 changes: 0 additions & 10 deletions common/src/main/kotlin/com/noheltcj/rxcommon/Subscription.kt

This file was deleted.

67 changes: 0 additions & 67 deletions common/src/main/kotlin/com/noheltcj/rxcommon/Transformation.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.noheltcj.rxcommon
package com.noheltcj.rxcommon.disposables

class CompositeDisposeBag : Disposable {
private val disposables = mutableListOf<Disposable>()
Expand All @@ -9,5 +9,6 @@ class CompositeDisposeBag : Disposable {

override fun dispose() {
disposables.forEach(Disposable::dispose)
disposables.clear()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.noheltcj.rxcommon.disposables

interface Disposable {
fun dispose()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.noheltcj.rxcommon.disposables

object Disposables {
fun create(onDispose: () -> Unit) : Disposable {
return InternalDisposable(onDispose)
}

fun empty() : Disposable {
return InternalDisposable {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.noheltcj.rxcommon.disposables

internal class InternalDisposable(private val onDispose: () -> Unit) : Disposable {
override fun dispose() {
onDispose()
}
}
Loading

0 comments on commit 987f7cd

Please sign in to comment.