Skip to content
forked from noheltcj/RxCommon

Multiplatform implementation of ReactiveX providing a common way to build one set of business logic for native, iOS, Javascript, Android, JVM, and other platforms.

License

Notifications You must be signed in to change notification settings

Hiosdra/RxCommon

 
 

Repository files navigation

RxCommon

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.

Sources

The reactivex documentation covers much of the functionality. If there are any significant discrepancies, excluding those I've illuminated within this documentation, please post an issue.

  • Observable
  • Single - Similar to observable, but will complete when the first value is emitted.
  • BehaviorRelay - Subject which ignores all notifications. Relays retain and emit the latest element.
  • BehaviorSubject - Similar to the BehaviorRelay, but acknowledges notifications
  • PublishSubject
  • More coming, I would gladly accept new collaborators / contributions.

Operators

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

Currently supported operators:

Installing

There are several places requiring imports to utilize this library.

Common Module

implementation "com.noheltcj:rx-common:0.2.0"

JVM Module

implementation "com.noheltcj:rx-common-jvm:0.2.0"

JavaScript Module

implementation "com.noheltcj:rx-common-js:0.2.0"

Native Module

Slightly more complicated. See the Native Distribution Limitation

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.

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.

About

Multiplatform implementation of ReactiveX providing a common way to build one set of business logic for native, iOS, Javascript, Android, JVM, and other platforms.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 99.8%
  • Shell 0.2%