js

A multiplatform ReactiveX partial implementation.

License

License

MIT
Categories

Categories

JavaScript Languages
GroupId

GroupId

com.noheltcj
ArtifactId

ArtifactId

rx-common-js
Last Version

Last Version

0.5.3
Release Date

Release Date

Type

Type

jar
Description

Description

js
A multiplatform ReactiveX partial implementation.
Project URL

Project URL

https://github.com/noheltcj/RxCommon
Source Code Management

Source Code Management

https://github.com/noheltcj/RxCommon

Download rx-common-js

How to add to project

<!-- https://jarcasting.com/artifacts/com.noheltcj/rx-common-js/ -->
<dependency>
    <groupId>com.noheltcj</groupId>
    <artifactId>rx-common-js</artifactId>
    <version>0.5.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.noheltcj/rx-common-js/
implementation 'com.noheltcj:rx-common-js:0.5.3'
// https://jarcasting.com/artifacts/com.noheltcj/rx-common-js/
implementation ("com.noheltcj:rx-common-js:0.5.3")
'com.noheltcj:rx-common-js:jar:0.5.3'
<dependency org="com.noheltcj" name="rx-common-js" rev="0.5.3">
  <artifact name="rx-common-js" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.noheltcj', module='rx-common-js', version='0.5.3')
)
libraryDependencies += "com.noheltcj" % "rx-common-js" % "0.5.3"
[com.noheltcj/rx-common-js "0.5.3"]

Dependencies

compile (2)

Group / Artifact Type Version
com.noheltcj : rx-common jar 0.5.3
org.jetbrains.kotlin : kotlin-stdlib-js jar 1.3.31

test (1)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-test-js jar 1.3.31

Project Modules

There are no modules declared in this project.

RxCommon

A multi-platform ReactiveX implementation targetting JVM, iOS, Android, and JS.

More targets can be added upon request.

Documentation

Please refer to https://reactivex.io for documentation.

Sources

The reactivex documentation covers much of the functionality. If there are any significant discrepancies, excluding those 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, new collaborators / contributions are greatly appreciated.

Operators

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

Currently supported operators:

Examples

Single(just = "hello")
  .map { "$it world" }
  .subscribe(NextObserver { result ->
    // result => "hello world"
  })

/* Be sure to dispose when this is no longer needed to prevent leaks. */
val disposable = Observable<String>(createWithEmitter = { emitter ->
  emitter.next("we're happy")
  emitter.next("la la la")

  Disposables.create {
    /*
     * This block is called when this cold observable loses all of its observers or
     * a notification is received. Use this to clean up any open connections, etc.
     */
  }
}).flatMap { happyText ->
  /* Use the text to maybe fetch something from an api. */
  return@flatMap Single<String>(error = UnauthorizedException()) // Uh oh, expired access
    .onErrorReturn { throwable ->
      /* Handle throwable, maybe check for unauthorized and recover */
      return@onErrorReturn Single(just = "$happyText recovery")
    }
}.subscribe(NextTerminalObserver({ emission ->
  /*
   * emission => "we're happy recovery"
   * emission => "la la la recovery"
   */
}, { throwable ->
  /* No terminal notifications in this example */
}))

Installing

Please ensure you're using gradle 5.3+.

Installing has recently become significantly easier. Now it's as simple as including the following:

Kotlin Build Script

kotlin {
    sourceSets {
        val commonMain by getting {
            dependencies {
                api("com.noheltcj:rxcommon:0.6.1")
            }
        }
    }
}

Groovy Build Script

kotlin {
    sourceSets {
        commonMain {
            dependencies {
                api 'com.noheltcj:rxcommon:0.6.1'
            }
        }
    }
}

Kotlin Support Map (For Native)

Since native modules require dependencies to be compiled with the same kotlin version, we will be keeping up with this support map going forward.

0.4.2 -> 1.3.20
0.5.0 -> 1.3.21
0.5.1 -> 1.3.21
0.5.2 -> 1.3.30
0.5.3 -> 1.3.31
0.6.0 -> 1.3.50
0.6.1 -> 1.3.61

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.

To help with this, when you produce an Objective-C framework, be sure to enable generics support.

components.main {
    outputKinds("framework")
    extraOpts "-Xobjc-generics"
}

Concurrency

This library doesn't support concurrency. In the majority of cases, concurrency is a side effect that can be handled on the platform. If you are doing anything that requires a significant amount of time to operate, it's important to do this work off the main thread (Especially if your application has a user interface). Of course do that using other resources such as RxSwift, RxJava, or basic platform concurrency frameworks, but ensure you've returned to the main thread before re-entering the common code.

Versions

Version
0.5.3
0.5.2
0.5.1
0.5.0
0.4.2
0.4.1
0.4.0
0.3.0
0.2.0
0.1.0
0.0.2