-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from noheltcj/v0.1.0
Release v0.1.0
- Loading branch information
Showing
54 changed files
with
2,481 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
common/src/main/kotlin/com/noheltcj/rxcommon/Subscription.kt
This file was deleted.
Oops, something went wrong.
67 changes: 0 additions & 67 deletions
67
common/src/main/kotlin/com/noheltcj/rxcommon/Transformation.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
common/src/main/kotlin/com/noheltcj/rxcommon/disposables/Disposable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.noheltcj.rxcommon.disposables | ||
|
||
interface Disposable { | ||
fun dispose() | ||
} |
11 changes: 11 additions & 0 deletions
11
common/src/main/kotlin/com/noheltcj/rxcommon/disposables/Disposables.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
common/src/main/kotlin/com/noheltcj/rxcommon/disposables/InternalDisposable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
Oops, something went wrong.